Skip to content
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

nvm uninstall fails due to permissions/globally installed modules via sudo #453

Open
ain opened this issue Jul 7, 2014 · 20 comments
Open
Labels
pull request wanted This is a great way to contribute! Help us out :-D uninstalling Issues uninstalling node/io.js versions.

Comments

@ain
Copy link

ain commented Jul 7, 2014

Steps to reproduce:

  1. nvm ls lists: .nvm, v0.10.26, -> v0.10.29
  2. nvm uninstall v0.10.26

What happens: v0.10.26 is not removed. nvm ls still lists: .nvm, v0.10.26, -> v0.10.29.

What should happen: v0.10.26 should be removed.

Platform:

node v0.10.29
grunt-cli v0.1.13
grunt v0.4.5 
@ljharb
Copy link
Member

ljharb commented Jul 7, 2014

if nvm ls lists .nvm, you must have an old version of nvm - what does nvm --version say?

Try installing the latest version (command is in the README) and try again.

@ain
Copy link
Author

ain commented Jul 7, 2014

Tried on another machine, worked now, but wget installation strategy did not work, had to use curl. wget is installed and works though.

@ljharb
Copy link
Member

ljharb commented Jul 7, 2014

Thanks, I'll consider that a separate issue.

@ljharb ljharb closed this as completed Jul 7, 2014
@ain
Copy link
Author

ain commented Jul 7, 2014

As erroneously reported under #455, here's what happens on uninstall for me:

mbpro-ain:~ ain$ nvm ls
    v0.10.26
->  v0.10.29
mbpro-ain:~ ain$ nvm uninstall v0.10.26
Uninstalled node v0.10.26
mbpro-ain:~ ain$ nvm ls
    v0.10.26
->  v0.10.29
mbpro-ain:~ ain$ nvm ls
    v0.10.26
->  v0.10.29
mbpro-ain:~ ain$ nvm --version
0.10.0

@ljharb ljharb reopened this Jul 7, 2014
@ljharb
Copy link
Member

ljharb commented Jul 7, 2014

What are your user permissions inside ~/.nvm (or $NVM_DIR if it's something else)?

@ain
Copy link
Author

ain commented Jul 7, 2014

drwxr-xr-x

@ain
Copy link
Author

ain commented Aug 2, 2014

I've just retried with the latest nvm version, here's the result:

ain$ node -v
v0.10.30
ain$ nvm --version
0.12.2
ain$ nvm list
    v0.10.26
    v0.10.29
->  v0.10.30
      system
ain$ nvm uninstall v0.10.26
Uninstalled node v0.10.26
ain$ nvm list
    v0.10.26
    v0.10.29
->  v0.10.30
      system

@ain
Copy link
Author

ain commented Aug 2, 2014

I turned off rm -rf silencing and turns out it fails to kill all modules that have been installed globally, e.g. npm install -g grunt, so as presumed, a file rights issue.

@ljharb
Copy link
Member

ljharb commented Aug 2, 2014

Definitely a permissions issue - perhaps we should remove that error silencing, so it's more apparent what's wrong? Or, we could simply print out a custom error message pointing out that some global modules weren't able to be removed.

@ain
Copy link
Author

ain commented Aug 2, 2014

I'd go with the sudo fallback asking for pass if it fails.

@ljharb
Copy link
Member

ljharb commented Aug 2, 2014

Would that work when run non-interactively? None of nvm's commands are meant to be interactive.

@ain
Copy link
Author

ain commented Aug 2, 2014

No it works if you modify to sudo rm -rf.

@ljharb
Copy link
Member

ljharb commented Aug 3, 2014

Good to know - but nvm shouldn't ever require sudo privileges. Perhaps it would be better to check permissions on $NVM_DIR on install, uninstall, and use, and report an error if they're incorrect, with another command (that used sudo) that repaired permissions?

@ain
Copy link
Author

ain commented Aug 3, 2014

The problem is many Node modules advise to install them globally with sudo, e.g. sudo npm install -g yo and that results in a corrupt NVM structure where file rights are incorrect.

@ljharb
Copy link
Member

ljharb commented Aug 3, 2014

Indeed - however, that's bad advice in any ecosystem :-( I'll think about how nvm can help ameliorate that.

@ljharb ljharb changed the title nvm uninstall fails nvm uninstall fails due to permissions/globally installed modules via sudo Nov 22, 2014
@usmonster
Copy link

Any update since 2014?

@ljharb
Copy link
Member

ljharb commented Aug 26, 2015

No, unfortunately I still don't know how nvm can help convince people to never use sudo npm install :-)

@usmonster
Copy link

In the case where the rm -rf of the uninstall doesn't succeed, maybe nvm can echo an informative message (as you suggested) that states the likely cause and recommends not using sudo with npm install? And/or a link to a wiki page or issue, e.g. this one or this page or npm/npm#3139, which suggests the best practice of using npm config set prefix /some/better/path -g and including /some/better/path/bin in the $PATH?

Maybe the root cause can eventually be addressed by a campaign to educate Node module authors to never recommend using sudo npm install, though the issue for that would have to be filed at the npm repo..

In the meantime, what do you think of the above suggestions? (Also, thanks for the quick response!)

@ljharb
Copy link
Member

ljharb commented Aug 26, 2015

Definitely do not set an npm prefix - that will break nvm, and in the near future, nvm will simply refuse to work if a prefix exists.

A message would be great - PRs are welcome :-)

@ljharb ljharb added the pull request wanted This is a great way to contribute! Help us out :-D label Aug 26, 2015
@usmonster
Copy link

Ah, I did not realize that.. Yep, it's right there in the README and in #606. 😁

Yeah, maybe I'll see about a PR, though it's much more likely that someone else would be able to get to it first. Thanks for adding the label!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pull request wanted This is a great way to contribute! Help us out :-D uninstalling Issues uninstalling node/io.js versions.
Projects
None yet
Development

No branches or pull requests

3 participants