[Error: EACCES: permission denied, scandir '/root/.npm/_logs']

hi everyone i am trying to setup my environment using sh ./scripts/database-init-docker.sh but i am reciving error
glob error [Error: EACCES: permission denied, scandir ‘/root/.npm/_logs’] {
errno: -13,
code: ‘EACCES’,
syscall: ‘scandir’,
path: ‘/root/.npm/_logs’

bbsite@0.0.0 prepublishOnly
npm run clean

Maybe @mr_monkey can help with this?

Hi @satyaarthchhabra and welcome !

I’m not exactly sure where the issue is coming from. Apparently you are missing permissions in the docker container when the image is built but i’m not sure why that is happening.
I just tried building the image myself succesfully, so I suspect the issue is with the interaction between Docker and your operating system.

To help me narrow it down abit, could you tell me what OS are you using, and what version of docker?

It would probably also be useful to see the whole logs; what I would propose is to run the command docker-compose build by itself (from your local bookbrainz-site folder), and paste the entire logs in a pastebin or something like that, and past the link here.

hi @mr_monkey i am currently using windows 10 pro and my docker version is 20.10.8 . and the log for the docker-compose build here

Thanks for providing more info. Looks like this is definitely a permissions issue with Docker on Windows. I’m not exactly sure how to solve the issue, and don’t have a windows machine to test it, so this might take a little while to solve!

In the logs you provided, we can see the we run into the issue when running the command npm run prepublishOnly which will call this cleanup script.
The error is not thrown when trying to delete the folders but rather internally in some NPM process trying to do something with logs: permission denied, scandir '/root/.npm/_logs'

My first suggestion would be to change line 47 in the Dockerfile to read instead:

USER node
RUN npm install --no-audit

That way the command npm install will be run with the node user (provided by the official node docker image that we are based on), which could solve the issue.

After that please try running docker-compose build again and see if you have better luck :slight_smile:

You can also try with USER root instead, which we wouldn’t want to do for production use but is fine for local development.

Let me know if any of this helps !

hi @mr_monkey , i tried both USER node and USER root in docker file but the error are same. i was readig a blog this might help. i tried with all methods provided here but none worked for me .

Hi @satyaarthchhabra ! Sorry I didn’t answer sooner.
I’m hitting the exact same issue you are after trying on a fresh repository clone, so it is not related to your setup at all, my bad!

I’m working on fixing this and will let you know once it’s ready.

I think I have fixed the issue, but would love your help to confirm it @satyaarthchhabra .
I’ve opened a couple of pull requests: one for the certificate issue and one for the permissions issue.
I’ve now merged those into master.
If you pull from master locally, rebuild the image and try running it again, please do let me know if that works for you.

1 Like

Another new contributor hit the same error while setting up, also someone running Docker on Windows.
The solution for them was to enable WSL2 (Windows Subsystem for Linux v2) and the problem went away

There is some incompatibility with Docker for Windows which I can’t replicate (not having a windows machine myself). If anyone is up for investigating this issue hit me up! :slight_smile: