npm config set giving EPERM - even if the file already belongs to the current user #7563
Comments
How are you becoming the user |
I guess that's the right trail. I'm logging in as 'sudo su'; I can reproduce the problem when doing That's interesting. |
Looks like you are running into code that tries to protect users from rendering .npmrc unwriteable when using "sudo npm config set foo" |
I'm having a problem with subprocesses of a service as well (it's a CI build agent), but I guess it might be the way I'm invoking the service itself. |
Rather that setting up a config file for your CI, have you tried passing config parameters on the command line or as environment variables?
|
But I'm not sure it helps me at all, as it's a maven build (apparently some of the maven plugins used in our build require color=false, and that's yet another yak to shave), but I saw no harm in executing the same maven execution locally and on CI. The easiest workaround to me is to create a maven profile and disable it in CI, but it feels to me it should work. |
It sounds like you have quite a complicate setup. I hope at least you feel like you have more options for how to configure npm than you had before. |
Looks like always starting the process as a Is this by design? |
I believe so. The most common problem with people using sudo is leaving files owned by root in the user's cache (or config). npm tries to work around that by detecting if you are running under sudo and trying to change ownership back to the original user. Running sudo su foo leaves a trace in the environment that you are under sudo, while sudo su - foo does not leave that trace, preventing npm from running the code that (while intended to fix one problem) ends up causing a problem for you. |
Thanks @smikes for that explanation - I ran into this as well after upgrading from npm 1.3.x to 2.8.4... For me, it manifested when trying to My workaround was to remove that line from the build script, and manage it externally instead, which makes me sad... Perhaps there could be a command-line option or config variable to disable the "prevent people from hurting themselves with sudo" logic? |
I ran into this same issue. Would it be possible to make the error message more informative? |
It's sad that this was closed, even after this...
It's clear that there's a few people hitting this "problem", and I dare say most of them aren't doing anything wrong. The original issue appears to have been people doing silly things, and that's always going to happen. Now we have a case where we can't do things we should be able to :( What would be required to consider the suggestion of an option to disable the "problematic code" via a command line option? |
For others reference, I was running something akin to this
and to avoid the warning I changed it to
to get past the warning |
This is clearly an environment problem, but I'm trying to understand what npm is actually executing when doing a config.
So, even if it actually saved the .npmrc file, and the group+user is correct, it's failing for some reason.
Trying it with sudo:
It worked, but I'm not sure why it needed sudo. There's a difference on the chmod of the file, but not the owner.
I can reproduce the problem both in prod environment and vagrant box. I upgraded from node 0.10.33, still same problem. Upgraded npm as well, no luck. I tried to give passwordless sudo, no change as well.
It's a ubuntu 14.04 box, I created the users using
adduser
command and puppet, I'm not sure that exactly is missing to get this working.npm 1.3.10 woks fine. But npm 2.7.0 or 2.5.1 doesn't.
The text was updated successfully, but these errors were encountered: