"npm rebuild" as non-root with sudo privileges breaks npm links #627

Closed
jbalonso opened this Issue Feb 22, 2011 · 2 comments

Projects

None yet

2 participants

@jbalonso

If I run "sudo npm rebuild", everything is fine (fresh install of node 0.4.2 and npm 0.3.4). If I run "npm rebuild", I see the following (punchline appears to be that npm will use privilege escalation for rm but not for linking):

npm info it worked if it ends with ok
npm info using npm@0.3.4
npm info using node@v0.4.2-pre
npm info preinstall npm@0.3.4
npm info privilege escalation rm /usr/local/lib/node/npm@0.3.4
npm info privilege escalation rm /usr/local/bin/npm@0.3.4
npm info privilege escalation rm /usr/local/bin/npm-get-uid-gid@0.3.4
npm info privilege escalation rm /usr/local/bin/read-package-json@0.3.4
npm ERR! linking /usr/local/lib/node/.npm/npm/0.3.4/package to /usr/local/lib/node/npm@0.3.4
npm ERR! linking /usr/local/lib/node/.npm/npm/0.3.4/package/bin/npm-get-uid-gid.js to /usr/local/bin/npm-get-uid-gid@0.3.4
npm ERR! failed to link bins
npm ERR! linking /usr/local/lib/node/.npm/npm/0.3.4/package/bin/npm.js to /usr/local/bin/npm@0.3.4
npm info privilege escalation rm /usr/local/share/man/man1/npm-uninstall@0.3.4.1
npm info privilege escalation rm /usr/local/share/man/man1/npm-coding-style@0.3.4.1
npm info privilege escalation rm /usr/local/share/man/man1/npm-registry@0.3.4.1
npm info privilege escalation rm /usr/local/share/man/man1/npm-set@0.3.4.1
npm ERR! linking /usr/local/lib/node/.npm/npm/0.3.4/package/bin/read-package-json.js to /usr/local/bin/read-package-json@0.3.4

...snip...
npm info privilege escalation rm /usr/local/share/man/man1/npm-new-module-system@0.3.4.1
npm info privilege escalation rm /usr/local/share/man/man1/npm-site@0.3.4.1
npm info privilege escalation rm /usr/local/share/man/man1/npm-remote@0.3.4.1
npm ERR! linking /usr/local/lib/node/.npm/npm/0.3.4/package/man1/uninstall.1 to /usr/local/share/man/man1/npm-uninstall@0.3.4.1
npm ERR! linking /usr/local/lib/node/.npm/npm/0.3.4/package/man1/coding-style.1 to /usr/local/share/man/man1/npm-coding-style@0.3.4.1
npm ERR! linking /usr/local/lib/node/.npm/npm/0.3.4/package/man1/registry.1 to /usr/local/share/man/man1/npm-registry@0.3.4.1

...snip...

npm ERR! linking /usr/local/lib/node/.npm/npm/0.3.4/package/man1/future-ideas/new-module-system.1 to /usr/local/share/man/man1/npm-new-module-system@0.3.4.1
npm ERR! linking /usr/local/lib/node/.npm/npm/0.3.4/package/man1/future-ideas/site.1 to /usr/local/share/man/man1/npm-site@0.3.4.1
npm ERR! linking /usr/local/lib/node/.npm/npm/0.3.4/package/man1/future-ideas/remote.1 to /usr/local/share/man/man1/npm-remote@0.3.4.1
npm info deactivate npm@0.3.4
npm info privilege escalation rm /usr/local/lib/node/npm
npm info privilege escalation rm /usr/local/bin/npm

...snip...

npm info privilege escalation rm /usr/local/share/man/man1/npm-new-module-system.1
npm info privilege escalation rm /usr/local/share/man/man1/npm-site.1
npm info privilege escalation rm /usr/local/share/man/man1/npm-remote.1
npm info postdeactivate npm@0.3.4
npm info preactivate npm@0.3.4
npm info activate npm@0.3.4
npm info postactivate npm@0.3.4
npm ok

Somehow, "npm ok" doesn't seem terribly accurate.

@jbalonso

As much as I appreciate the intended ease-of-use behind automatic privilege escalation, I (and certainly many others) expect commands that alter the system to fail loudly and harmlessly when executed without "sudo" in front. In that regard, there is something perverse about "npm rebuild" being more destructive (or even having the capability of being more destructive) than "sudo npm rebuild".

@isaacs
npm member

Yeah, I'm pulling that automatic privilege escalation. It doesn't actually do very well in a lot of cases anyway. So, the good news is this bug should go away in the next drop today :)

@indexzero indexzero pushed a commit that referenced this issue Apr 19, 2011
@isaacs isaacs Closes GH-627 Revert 'rm privilege escalation'. Causes issues.
Reverts the following commits:

* 1679d41 isaacs privilege escalation is an info, not a warn (2 weeks ago)
* 08e59c1 isaacs Cooler prompt (2 weeks ago)
* b43a6ae isaacs Escalate perms when rm fails. (2 weeks ago)
a483668
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment