nvm-sh / nvm

Node Version Manager - POSIX-compliant bash script to manage multiple active node.js versions

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

nvm install node fails to install on Ubuntu 22.04

Shadowbeetle opened this issue · comments

I'm trying to install the latest version of node using nvm, but I'm simply getting nvm: install v19.3.0 failed! with no further explanation. It does fail the binary download, but I have the build-essential package installed as well.

Operating system and version:

Ubuntu 22.04.1 LTS

nvm debug output:

nvm --version: v0.39.3
$TERM_PROGRAM: vscode
$SHELL: /usr/bin/zsh
$SHLVL: 2
whoami: 'tamas'
${HOME}: /home/tamas
${NVM_DIR}: '${HOME}/.nvm'
${PATH}: ${HOME}/.fly/bin:${HOME}/.local/bin:${HOME}/.rbenv/bin:${HOME}/.mix/escripts:/home/nazgul/.deno/bin:${HOME}/.fly/bin:${HOME}/.local/bin:${HOME}/.rbenv/bin:${HOME}/.mix/escripts:/home/nazgul/.deno/bin:${HOME}/.zinit/plugins/docker---compose:${HOME}/.zinit/plugins/starship---starship:${HOME}/.zinit/polaris/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin:${HOME}/.fzf/bin:/snap/bin:/usr/local/go/bin:${HOME}/.cargo/bin:${HOME}/.rvm/bin:/snap/bin:/usr/local/go/bin:${HOME}/.cargo/bin:${HOME}/.rvm/bin
$PREFIX: ''
${NPM_CONFIG_PREFIX}: ''
$NVM_NODEJS_ORG_MIRROR: ''
$NVM_IOJS_ORG_MIRROR: ''
shell version: 'zsh 5.8.1 (x86_64-ubuntu-linux-gnu)'
uname -a: 'Linux 5.15.0-56-generic #62-Ubuntu SMP Tue Nov 22 19:54:14 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux'
checksum binary: 'sha256sum'
OS version: Ubuntu 22.04.1 LTS  
random-funcs:       srandom/random
regex-funcs:        internal
compiled limits:
sprintf buffer      8192
maximum-integer     2147483647
awk: /usr/bin/awk, mawk 1.3.4 20200120
curl: /usr/bin/curl, curl 7.81.0 (x86_64-pc-linux-gnu) libcurl/7.81.0 OpenSSL/3.0.2 zlib/1.2.11 brotli/1.0.9 zstd/1.4.8 libidn2/2.3.2 libpsl/0.21.0 (+libidn2/2.3.2) libssh/0.9.6/openssl/zlib nghttp2/1.43.0 librtmp/2.3 OpenLDAP/2.5.13
wget: /usr/bin/wget, GNU Wget 1.21.2 built on linux-gnu.
git: /usr/bin/git, git version 2.34.1
ls: cannot access 'grep:': No such file or directory
grep: grep: aliased to grep --color=auto (grep --color=auto), grep (GNU grep) 3.7
sed: /usr/bin/sed, sed (GNU sed) 4.8
cut: /usr/bin/cut, cut (GNU coreutils) 8.32
basename: /usr/bin/basename, basename (GNU coreutils) 8.32
ls: cannot access 'rm:': No such file or directory
rm: rm: aliased to rm -i (rm -i), rm (GNU coreutils) 8.32
mkdir: /usr/bin/mkdir, mkdir (GNU coreutils) 8.32
xargs: /usr/bin/xargs, xargs (GNU findutils) 4.8.0
nvm current: none
which node: node not found
which iojs: iojs not found
which npm: npm not found
npm config get prefix: nvm:271: command not found: npm
npm root -g: nvm:271: command not found: npm

nvm ls output:

            N/A
iojs -> N/A (default)
node -> stable (-> N/A) (default)
unstable -> N/A (default)
lts/* -> lts/hydrogen (-> N/A)
lts/argon -> v4.9.1 (-> N/A)
lts/boron -> v6.17.1 (-> N/A)
lts/carbon -> v8.17.0 (-> N/A)
lts/dubnium -> v10.24.1 (-> N/A)
lts/erbium -> v12.22.12 (-> N/A)
lts/fermium -> v14.21.2 (-> N/A)
lts/gallium -> v16.19.0 (-> N/A)
lts/hydrogen -> v18.12.1 (-> N/A)

How did you install nvm?

install script in readme

What steps did you perform?

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.39.3/install.sh | bash
nvm install node

What happened?

$ nvm install node
[... tons of variable values printed to the console ...]
Binary download failed, trying source.
Local cache found: ${NVM_DIR}/.cache/src/node-v19.3.0/node-v19.3.0.tar.xz
Checksums match! Using existing downloaded archive ${NVM_DIR}/.cache/src/node-v19.3.0/node-v19.3.0.tar.xz
nvm: install v19.3.0 failed!

What did you expect to happen?

Latest node version gets installed.

Hmm, that's strange. Does nvm install 18 or nvm install 16 work? 18+ made some changes to compilation that might be relevant.

Also, have you tried this in a real terminal? vscode doesn't count as one :-)

I tried first in a real terminal. :) Only tried in vscode too, because it was easier to copy from there.

Tried installing both 16 and 18, but got the same result.

Thanks for ruling those out :-)

One thing worth trying is to install node yourself by downloading the source from nodejs.org. if it works that way, it's something nvm is doing wrong, but if it doesn't work that way, then you'd need to file an issue with node itself to figure out how to get node to compile on your system (at which point, nvm might be able to make the process easier by automating those steps!)

No, thanks for guiding me through this! :)

I managed to compile node v18.12.1 from source, so it might be something with nvm. Is there a way to get a more verbose output?

You can set -x - the output will be very verbose.

Thanks! I'll try it in the afternoon. Some more info in the meantime: asdf found the binaries for 18.12 and 16.16 without a problem.

Tried with bash instead of zsh, and it found the prebuilt binaries, so it's probably something with my .zshrc. Which is strange, as I use the same on Ubuntu with WSL, and there I had no problems at all.

I've given a couple of shots to running nvm with set -x. It's not as easy, as I initially expected.

Setting -x simply in the interactive session results in zsh periodically printing the commands it's running in the background.

So I tried adding it to the nvm shell function at ~/.nvm/nvm.sh, then source-ing it, but that abruptly kills my shell, and prevents me from starting new ones.

My other idea was to try it with an interactive bash session, but as I mentioned before, it works there without any problems. So I'm a bit stuck at this point.

If it's specific to zsh, the culprit is surely one of the zsh options. What's the output of setopt?

If you binary search, you may be able to figure out which one is breaking the installation, and then i can patch nvm to be robust to it.

The setopt output is:

alwaystoend
autopushd
completeinword
extendedhistory
noflowcontrol
histexpiredupsfirst
histignoredups
histignorespace
histverify
interactive
monitor
promptsubst
pushdignoredups
pushdminus
sharehistory
shinstdin
zle

My stock zsh only has

combiningchars
interactive
monitor
shinstdin
zle

i'm not familiar with lwaystoend, and my hunch is that's the issue - can you confirm?

Sorry, my mistake, I did not copy the first character of alwaystoend

However, I've checked unsetopt-ing them one by one, and turned off everything but interactive and shinstdin, but still no dice.

ah, makes sense.

hmm, that's also unfortunate, because then it's unclear what's different between your zsh and bash. What happens if you comment out the NVM_LAZY_LOAD line?

Still not working :(

Let me create a gist and share the tons of log with you, maybe you can make sense of it.

well, https://gist.github.com/Shadowbeetle/adfbcf9db76a476703a239847c273d8b#file-gistfile1-txt-L3 seems suspect, as does https://gist.github.com/Shadowbeetle/adfbcf9db76a476703a239847c273d8b#file-gistfile1-txt-L1673 - is there maybe some kind of missing quote somewhere in your zsh plugins that might be causing this? Maybe Zinit? (i'm not sure what that is)

zinit is basically a plugin manager like antigen.

Shouldn't a missing quote prevent the code from running at all? I mean, if there is an unclosed quote somewhere wouldn't it result in the mkdir command to be taken as part of the string?

What about the awk error?

https://gist.github.com/Shadowbeetle/adfbcf9db76a476703a239847c273d8b#file-gistfile1-txt-L2

And now that I take a closer look at line 3, the file path string starts with ‘ (charCode: 8216) instead of ' (charCode: 39). Is that expected?

(Edit: forgot to finish the first sentence)

Either way, you were right!

It seems the common-aliases Oh My Zsh plugin caused the problem. I cannot see any unclosed quotes in there, or anything else fishy though.

Moving it down to the bottom of my .zshrc solved the issue anyhow. It just bothers me, that I don't understand what the actual reason was.

If you don't mind, I'll take down the gist. I'm feeling a bit exposed it being online.

Thank you anyway, the problem is solved!

ahhh - it's probably the L alias, which means this was a duplicate of #2963 :-)

I had the same problem but even when i removed oh my zsh extension on both zsh and bash doesn't fix the problem.
i didn't manage to get the source of the problem but i fix it at my own buy making nvm use wget instead of curl!!

I had the same problem, but when i downloaded install.sh file in my local and just ran the bash install.sh in my linux terminal, it worked perfectly fine :)