nvm-sh / nvm

Node Version Manager - POSIX-compliant bash script to manage multiple active node.js versions
MIT License
80.03k stars 8.01k forks source link

Can't uninstall node version #1982

Closed matheusgrieger closed 5 years ago

matheusgrieger commented 5 years ago
ljharb commented 5 years ago

What happens if you set -x before running nvm uninstall 10.9? (it'll be a lot of output; let's hide it behind a <details>)

matheusgrieger commented 5 years ago

I can't copy the output, the terminal window closes when running nvm uninstall. What can I do to keep it open?

matheusgrieger commented 5 years ago

Ok, I have managed to keep it alive, here's the output.

```sh +nvm_check_file_permissions:1> setopt local_options nonomatch +nvm_check_file_permissions:2> FILE=/home/matheus/.nvm/versions/node/v10.9.0/lib/node_modules/cordova/node_modules/cordova-js/tasks/vendor/commonjs-tests/modules/1.0/nested/a/b +nvm_check_file_permissions:3> [ -d /home/matheus/.nvm/versions/node/v10.9.0/lib/node_modules/cordova/node_modules/cordova-js/tasks/vendor/commonjs-tests/modules/1.0/nested/a/b ']' +nvm_check_file_permissions:4> nvm_check_file_permissions /home/matheus/.nvm/versions/node/v10.9.0/lib/node_modules/cordova/node_modules/cordova-js/tasks/vendor/commonjs-tests/modules/1.0/nested/a/b +nvm_check_file_permissions:1> nvm_is_zsh +nvm_is_zsh:1> [ -n 5.4.2 ']' +nvm_check_file_permissions:1> setopt local_options nonomatch +nvm_check_file_permissions:2> FILE=/home/matheus/.nvm/versions/node/v10.9.0/lib/node_modules/cordova/node_modules/cordova-js/tasks/vendor/commonjs-tests/modules/1.0/nested/a/b/c +nvm_check_file_permissions:3> [ -d /home/matheus/.nvm/versions/node/v10.9.0/lib/node_modules/cordova/node_modules/cordova-js/tasks/vendor/commonjs-tests/modules/1.0/nested/a/b/c ']' +nvm_check_file_permissions:4> nvm_check_file_permissions /home/matheus/.nvm/versions/node/v10.9.0/lib/node_modules/cordova/node_modules/cordova-js/tasks/vendor/commonjs-tests/modules/1.0/nested/a/b/c +nvm_check_file_permissions:1> nvm_is_zsh +nvm_is_zsh:1> [ -n 5.4.2 ']' +nvm_check_file_permissions:1> setopt local_options nonomatch +nvm_check_file_permissions:2> FILE=/home/matheus/.nvm/versions/node/v10.9.0/lib/node_modules/cordova/node_modules/cordova-js/tasks/vendor/commonjs-tests/modules/1.0/nested/a/b/c/d.js realloc(): invalid next size [1] + 13429 abort (core dumped) nvm uninstall 10.9 +-zsh:5> nvm_prompt_info +nvm_prompt_info:1> [[ -f /home/matheus/.nvm/nvm.sh ]] +nvm_prompt_info:2> local nvm_prompt +nvm_prompt_info:3> nvm_prompt=+nvm_prompt_info:3> node -v +nvm_prompt_info:3> nvm_prompt=v10.15.0 +nvm_prompt_info:4> [[ v10.15.0x == x ]] +nvm_prompt_info:5> nvm_prompt=10.15.0 +nvm_prompt_info:6> echo '%B⬡%b 10.15.0' +-zsh:5> bureau_git_prompt +bureau_git_prompt:1> bureau_git_branch +bureau_git_branch:1> ref=+bureau_git_branch:1> git symbolic-ref HEAD +bureau_git_branch:1> ref='' +bureau_git_branch:2> ref=+bureau_git_branch:2> git rev-parse --short HEAD +bureau_git_branch:2> ref='' +bureau_git_branch:2> return +bureau_git_prompt:1> local _branch='' +bureau_git_prompt:2> bureau_git_status +bureau_git_status:1> _STATUS='' +bureau_git_status:4> _INDEX=+bureau_git_status:4> git status --porcelain +bureau_git_status:4> _INDEX='' +bureau_git_status:5> [[ -n '' ]] +bureau_git_status:19> _STATUS=$'%{\C-[[01;32m%}✓%{\C-[[00m%}' +bureau_git_status:23> _INDEX=+bureau_git_status:23> git status --porcelain -b +bureau_git_status:23> _INDEX='' +bureau_git_status:24> echo '' +bureau_git_status:24> grep -q '^## .*ahead' +bureau_git_status:27> echo '' +bureau_git_status:27> grep -q '^## .*behind' +bureau_git_status:30> echo '' +bureau_git_status:30> grep -q '^## .*diverged' +bureau_git_status:34> git rev-parse --verify refs/stash +bureau_git_status:38> echo $'%{\C-[[01;32m%}✓%{\C-[[00m%}' +bureau_git_prompt:2> local _status=$'%{\C-[[01;32m%}✓%{\C-[[00m%}' +bureau_git_prompt:3> local _result='' +bureau_git_prompt:4> [[ x != x ]] +bureau_git_prompt:11> echo ```

I have not included most of the output, since it took all available lines from the terminal window, and that would be too much.

ljharb commented 5 years ago

Thanks, so it's failing in nvm_check_file_permissions - presumably you can reproduce this with nvm_check_file_permissions "$(nvm_version_path v10.9.0)"?

Any chance /home/matheus/.nvm/versions/node/v10.9.0/lib/node_modules/cordova/node_modules/cordova-js/tasks/vendor/commonjs-tests/modules/1.0/nested contains some symlinks, or some files with weird permissions?

matheusgrieger commented 5 years ago

presumably you can reproduce this with nvm_check_file_permissions "$(nvm_version_path v10.9.0)"?

Apparently not, without set -x there is no output whatsoever. With it, though, there are loads of outputs, but nothing that seems intereseting. It doesn't fail with that same error.

contains some symlinks, or some files with weird permissions?

Not that I could see. They are simple files with common permissions and my user is currently the owner of all of them. However I'm not quite sure how to look for those (I'm not that savvy with Linux).

matheusgrieger commented 5 years ago

I have noticed something interesting. When using Tab to autocomplete folders and Git branches, I'm getting the same realloc error. Is it something to do with zsh or oh-my-zsh, maybe?

ljharb commented 5 years ago

That's entirely possible - you could try disabling the autocompletion temporarily and see if that makes a difference.

matheusgrieger commented 5 years ago

Sorry! I have had my laptop changed in the past couple of days and I'm not using a Linux system anymore. However, since I have access to my old one still, I will test it out during the weekend and follow up on the issue.

nickdesaulniers commented 5 years ago

So I'm also seeing my 2 different terminals close when I run nvm uninstall 8.4. I'm also using zsh. nvm --version is 0.34.

$ nvm --version
0.34.0
$ set -x
$  nvm uninstall 8.4 &> log.txt
$ tail -n6 log.txt
+nvm_check_file_permissions:1> nvm_is_zsh
+nvm_is_zsh:1> [ -n 5.4.2 ']'
+nvm_check_file_permissions:1> setopt local_options nonomatch
+nvm_check_file_permissions:2> FILE=/home/nick/.nvm/versions/node/v8.4.0/lib/node_modules/npm/node_modules/libnpx/node_modules/yargs/node_modules/cliui/node_modules/string-width/node_modules/is-fullwidth-code-point/node_modules/number-is-nan
+nvm_check_file_permissions:3> [ -d /home/nick/.nvm/versions/node/v8.4.0/lib/node_modules/npm/node_modules/libnpx/node_modules/yargs/node_modules/cliui/node_modules/string-width/node_modules/is-fullwidth-code-point/node_modules/number-is-nan ']'
realloc(): invalid next size

log.txt

nickdesaulniers commented 5 years ago

I suspect this is a bug in zsh, simply exposed via nvm. Google-ing the above error message plush zsh turns up lots of hits.

Sounds like zsh 5.5 and newer fix this: https://github.com/rvm/rvm/issues/4214#issuecomment-398786401. I'm running:

➜  node-nanomsg git:(gypi) zsh --version
zsh 5.4.2 (x86_64-ubuntu-linux-gnu)

(I recommend the maintainers close this bug)