-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] npm start suddenly started giving npm ERR! Error: EACCES: permission denied, mkdir '/home/myuser'
as of yesterday (2023-11-30)
#7044
Comments
I also encountered the same issue on December 1st at 00:00 UTC when the application restarted. The system had not upgraded the Node and npm versions, and there were no changes to the application code while running the application. I am also wondering about the reason for this issue. |
For your information, another workaround for this problem is to specify the cache directory in your
|
For people who are running this in containers they can't easily rebuild and redeploy it also worked for me to override the dns entry for registry.npmjs.org (I tried setting it to 127.0.0.1 in /etc/hosts). Please report this issue to npm through the npm website as well. If you log in to your npm account you can report an issue with the registry. Maybe someone will get through to someone who understands the problem. |
IBM products that use How do we lobby for the change to be modified or reverted (and to consider a |
Yes it’s pretty scary that images that have been running fine for a year suddenly breaks. It should probably be easy for npm to fix this if it was possible to get their attention. We have already moved away from using npm in the docker images going forward but these old containers are running in a lot of places where we don’t have access to upgrade them. @dglozic You can avoid the outgoing request if you set the config variable as mentioned in the ticket. |
I understand that (thanks!) but that requires changes to the images. |
Since it is an environment variable it should be possible to change it without changing the image assuming you have access to relaunch the container. We did this in our kubernetes environments as a hot-fix yesterday. |
Ah sorry, was not paying attention, I was seeing changes to .npmrc and didn't see that an env var can do the same. |
Can anyone from the community explain a bit on what is causing this problem? We are getting more and more reports from customers on this issue. |
I assume blocking all egress by default, and then defining only required exceptions (using network policies) would also work, as long as you don't add registry.npmjs.org to that exception list. Container images are generally assumed to be static, ideally they shouldn't be updating themselves over the internet at start time. |
I will be digging into why this has been happening. My goal is to triage and fix this week to be included in our next release. |
Perhaps it would be good to re-iterate that it's the best practice that containers running in production shall run with the read-only filesystem ( I would assume the issue will be investigated and root cause explained as of WHY the issue started to be seen on Nov 30th/Dec 1st, but I'd suggest that there is a solid review executed against any other places where |
For deployments in k8s, images starting using NPM start need NPM to:
I don’t know which combination of cli options would yield such behaviour but it seems important for runtime image starts. |
We experienced the same issue on an older version of npm 8.5.0. We were using an AWS EC2 AMI which had started up fine many times previously then stopped working on 30th. |
This is one of the goals on my investigation, and is currently a goal of I don't have any thorough conclusions yet, but so far I have found that an uncaught promise or stream error is bubbling up unexpectedly to our uncaught exception handler. |
The update notifier is designed to run weekly and will attempt to contact the configured registry to see if This can be turned off with the following command which will set the config in a local
|
Thanks @lukekarrys - that is useful! |
Today's npm release (10.2.5) will be the one that has the ETA: it will also have the update notifier fix, but that only fixes folks who are not doing any registry fetch w/ npm. |
I appreciate your hard work. It seems that patch fixes the phenomenon, but anyway I would like to know why did this problem begin on 30 Nov or 1st Dec? As I mentioned above, there had been no changes of npm/node runtime on the user side. |
I'm going to leave this issue open as I continue to investigate deeper. We've landed a fix for this specific bug, but there are the issues of the uncaught exception as well as why this bug started appearing. I'll use this issue to report my findings. |
@willisweb which version of nodejs was this on? |
@lukekarrys, I can answer for us (different company from @willisweb). Initially, we encountered this issue with npm 8.5.5 and Node.js version 16.15.0. These versions had been functioning properly for an extended period until about a week ago, when we began experiencing the reported problem. This prompted me to replicate the issue using the most recent version of npm, after which I created this bug report... |
Did those who saw the phenomenon at the beginning of December take the Thanksgiving holiday off? Had it been a week since you ran npm? |
We had an EC2 in production using npm in a systemd enabled service (so And we're in the UK so have no concept of Thanksgiving ;) |
Thanks to everyone for the attention this has been given so far. It would be useful to know if this issue has been downgraded in priority because using the npm CLI in production in the ways described in this thread isn't an expected use-case for the tool? It would be useful to know since we can adjust our expectations accordingly. |
It was downgraded because yesterday's npm release fixed the reported issue. npm instances that don't run commands that fetch registry info will no longer crash. It was left open because there are some other issues (such as how the error and ones similar to it manifested) that still need attention. |
Please note that it can take weeks for this new npm version to make it down into new docker images (the new version has to land in a new version of node, and then that new version of node has to make it to a docker image), so you may want to consider manually updating npm in your workflows to stay current. |
Hi Since we don't know yet why the issue happened on Nov the 30rd, we do not know if and when it could happen again. So for new application that will use My opinion is that understanding the root cause of the issue is the priority, and then fixing it for sure. My 2 cents, and thanks for the support ! |
@wraithgar Will the fix also applied to the old such as NPM 8.5.X version? As we have many images using npm 8.5.0 and 8.5.5. Thanks! |
No this will only be fixed in npm 10 as of right now, specifically 10.2.5 or newer. For older versions you will want to disable the update notifier. npm 10 is the only supported version of npm as it's the only version of npm that ships with all currently supported versions of node. npm 9 does get occasional backports but they're not guaranteed, we are doing them to iron out the backport process for when we cut npm 11 not as a support contract. npm 8 hasn't had an update in 9 months. We also can't fix an existing version of npm. Even if a new version of npm 8 were to be published 8.5.0 and 8.5.5 won't ever change. |
I just want to point out that this is what everyone thought, but it didn't turn out to be the case. Do we understand why v8 suddenly changed behaviour on Nov. 30? |
@eamonnsullivan presumably it changed behavior at midnight UTC on December 1st, which was November 30th for many. |
It was nodejs v16.14.2 |
I would just like to make it clear, in case it wasn't above that for us running instances were unaffected, so they didn't poll and then fail, it was only new instances starting up from an AMI that was previously started multiple times without issue that were affected. |
@lukekarrys Sorry, I don't mean to rush you but are there any updates? Actually I would like to know the root cause of this issue. |
This comment has been minimized.
This comment has been minimized.
A teammate of mine just told me that she hasn't encountered this issue at all this week. Is it truly fixed? |
Is there an existing issue for this?
This issue exists in the latest npm version
Current Behavior
We do
npm start
in a Docker container with a user which doesn't have a home directory. We've been doing this for several years without problems, but as of yesterday (2023-11-30) all containers suddenly getnpm ERR! Error: EACCES: permission denied, mkdir '/home/myuser'
. SettingNPM_CONFIG_UPDATE_NOTIFIER=false
solves this problem, but we've already deployed a lot of containers without the update notifier disabled which causes a lot of problems for us.Did something change in the response from the npm servers or do you know why this problem suddenly started happening yesterday?
Expected Behavior
npm start
should start the script and not exit due to being unable to create a home folder.Steps To Reproduce
Given the following code as
repro.sh
:./repro.sh
orNPM_CONFIG_UPDATE_NOTIFIER=true ./repro.sh
causes npm to exit with the following log:But
NPM_CONFIG_UPDATE_NOTIFIER=false ./repro.sh
works:Environment
The text was updated successfully, but these errors were encountered: