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

Can't uninstall version if lib/node_modules contain a symlink #1270

Closed
watson opened this issue Oct 24, 2016 · 7 comments
Closed

Can't uninstall version if lib/node_modules contain a symlink #1270

watson opened this issue Oct 24, 2016 · 7 comments
Assignees
Labels
bugs Oh no, something's broken :-( uninstalling Issues uninstalling node/io.js versions.

Comments

@watson
Copy link

watson commented Oct 24, 2016

Environment:

  • nvm version: latest
  • shell: zsh

When doing local module development, you'd sometimes run the npm link command with is kind of like installing the module you're working on globally. But instead of actually copying the bin files it just creates a symlink to your code.

If I then try to run nvm uninstall <x> the uninstaller will fail with the following message:

% nvm uninstall 4.4                              
file is not writable: $NVM_DIR/versions/node/v4.4.5/lib/node_modules/test-all-versions/.git/objects/01/0300c6d46fc154cec38182e38713bed887a6c7
Cannot uninstall, incorrect permissions on installation folder.
This is usually caused by running `npm install -g` as root. Run the following commands as root to fix the permissions and then try again.

  chown -R watson "$NVM_DIR/versions/node/v4.4.5"
  chmod -R u+w "$NVM_DIR/versions/node/v4.4.5"

The issue is not resolved by running the two commands and a peak inside $NVM_DIR/versions/node/v4.4.5/lib/node_modules shows you:

% ls -l $NVM_DIR/versions/node/v4.4.5/lib/node_modules 
total 8
drwxr-xr-x   8 watson  staff  272 Jun  7 10:37 airtar
drwxr-xr-x   9 watson  staff  306 Jun  5 11:20 bcc
drwxr-xr-x  13 watson  staff  442 Aug 30 17:18 coffee-script
drwxr-xr-x  16 watson  staff  544 May 26 16:43 dat
drwxr-xr-x   7 watson  staff  238 Jul  7 23:00 geo-legacy
drwxr-xr-x  11 watson  staff  374 Jun  3 21:53 geopkg
drwxr-xr-x   8 watson  staff  272 May 27 09:40 git-ps1
drwxr-xr-x   6 watson  staff  204 Jun 30 14:53 greenkeeper
drwxr-xr-x  12 watson  staff  408 Jun 12 04:07 gulp
drwxr-xr-x   9 watson  staff  306 Jun 16 21:47 http-traceroute
drwxr-xr-x  15 watson  staff  510 Jul  2 13:43 ipp-printer
drwxr-xr-x  19 watson  staff  646 Jul  1 21:54 node-inspector
drwxr-xr-x  18 watson  staff  612 Jul 20 15:59 nodemon
drwxr-xr-x  23 watson  staff  782 May 24 19:30 npm
drwxr-xr-x  11 watson  staff  374 Jun  5 10:49 npm-available
drwxr-xr-x  11 watson  staff  374 Jun 23 20:18 peerflix
drwxr-xr-x  18 watson  staff  612 Aug 24 17:36 standard
drwxr-xr-x  24 watson  staff  816 Jun  5 09:37 t2-cli
lrwxr-xr-x   1 watson  staff   49 Jun 19 06:53 test-all-versions -> /Users/watson/code/node_modules/test-all-versions

If I instead manually remove the symlink:

% rm $NVM_DIR/versions/node/v4.4.5/lib/node_modules/test-all-versions 

Then the uninstall is able to complete

@ljharb
Copy link
Member

ljharb commented Oct 24, 2016

Thanks for the report! I've recently run into the same issue, and I'm working on a fix locally as we speak. (Manually running npm unlink -g also resolves it)

@ljharb ljharb added uninstalling Issues uninstalling node/io.js versions. bugs Oh no, something's broken :-( labels Oct 24, 2016
@ljharb ljharb self-assigned this Oct 24, 2016
@watson
Copy link
Author

watson commented Oct 24, 2016

@ljharb Is there a risk that it's trying to delete the data inside my code folder by following the symlink? E.g. do you know if it might have deleted some data in there before getting the error mentioned above?

@ljharb
Copy link
Member

ljharb commented Oct 24, 2016

No, the point of that error is that nothing is deleted until it passes. In addition, it wouldn't have removed the symlink contents, just the link itself, so your data is safe.

@ljharb ljharb closed this as completed in e5316dd Nov 13, 2016
edwmurph pushed a commit to edwmurph/nvm that referenced this issue Apr 9, 2018
@keywordnew
Copy link

Just encountered this problem. Guessing I'm on a version of nvm without the fix: 0.31.7 @ljharb?

Manually removed the symlinks as suggested by @watson in original comment and nvm uninstall ran fine 💯

@ljharb
Copy link
Member

ljharb commented May 16, 2018

@chowdhurian either way you should update to v0.33.11 - specifically tho, the fix is in v0.33.9, as you can see from the commit

@IoriBranford
Copy link

Still can occur in nvm 0.39.5, when you try to uninstall node 18.15.0.

The problem file in my case was ${NVM_DIR}/versions/node/v18.15.0/lib/node_modules/netlify-cli/node_modules/unix-dgram/build/node_gyp_bins/python3 -> /usr/bin/python3. The permission fix did not work.

@ljharb
Copy link
Member

ljharb commented Sep 11, 2023

@IoriBranford i think 1eaaada (currently unreleased) may fix that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugs Oh no, something's broken :-( uninstalling Issues uninstalling node/io.js versions.
Projects
None yet
Development

No branches or pull requests

4 participants