nvm: Failed to install with errors; First error is Permission Denied; then Binary download failed, trying source.

Operating system and version:

Windows 10, but installing under WSL2 / Ubuntu 20.04

nvm debug output:

nvm --version: v0.38.0
$SHELL: /bin/bash
$SHLVL: 1
whoami: 'joliunix'
${HOME}: /home/joliunix
${NVM_DIR}: '${HOME}/.nvm'
${PATH}: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/mnt/c/Program Files/WindowsApps/CanonicalGroupLimited.UbuntuonWindows_2004.2021.222.0_x64__79rhkp1fndgsc:/mnt/c/ProgramData/Oracle/Java/javapath:/mnt/c/WINDOWS/system32:/mnt/c/WINDOWS:/mnt/c/WINDOWS/System32/Wbem:/mnt/c/WINDOWS/System32/WindowsPowerShell/v1.0/:/mnt/c/Program Files/Microsoft SQL Server/110/Tools/Binn/:/mnt/c/Program Files (x86)/Microsoft SDKs/TypeScript/1.0/:/mnt/c/Users/Joli/.dnx/bin:/mnt/c/Program Files/Microsoft DNX/Dnvm/:/mnt/c/Program Files/Microsoft SQL Server/130/Tools/Binn/:/mnt/c/Program Files (x86)/Microsoft Emulator Manager/1.0/:/mnt/c/Program Files (x86)/Windows Kits/10/Windows Performance Toolkit/:/mnt/c/Program Files/Microsoft SQL Server/120/DTS/Binn/:/mnt/c/Program Files/Microsoft SQL Server/Client SDK/ODBC/110/Tools/Binn/:/mnt/c/Program Files (x86)/Microsoft SQL Server/120/Tools/Binn/:/mnt/c/Program Files/Microsoft SQL Server/120/Tools/Binn/:/mnt/c/Program Files (x86)/Microsoft SQL Server/120/Tools/Binn/ManagementStudio/:/mnt/c/Program Files (x86)/Microsoft SQL Server/120/DTS/Binn/:/mnt/c/Program Files/Microsoft/Web Platform Installer/:/mnt/c/Program Files/Intel/WiFi/bin/:/mnt/c/Program Files/Common Files/Intel/WirelessCommon/:/mnt/c/WINDOWS/System32/OpenSSH/:/mnt/c/Program Files/Microsoft VS Code/bin:/mnt/c/Program Files/Git/cmd:/mnt/d/ProgramFiles/PostgreSQL/10/bin:/mnt/c/Program Files (x86)/Notepad++/:/mnt/c/Program Files (x86)/Microsoft SQL Server/Client SDK/ODBC/130/Tools/Binn/:/mnt/c/Program Files (x86)/Microsoft SQL Server/140/Tools/Binn/:/mnt/c/Program Files (x86)/Microsoft SQL Server/140/DTS/Binn/:/mnt/c/Program Files (x86)/Microsoft SQL Server/140/Tools/Binn/ManagementStudio/:/mnt/c/Program Files/nodejs/:/mnt/d/ProgramFiles/GnuPG/bin:/mnt/c/Program Files (x86)/Microsoft VS Code/bin:/mnt/c/Program Files/heroku/bin:/mnt/c/Users/Joli/AppData/Local/Microsoft/WindowsApps:/mnt/c/Users/Joli/AppData/Roaming/npm:/mnt/c/Users/Joli/AppData/Local/Programs/Fiddler:/snap/bin
$PREFIX: ''
${NPM_CONFIG_PREFIX}: ''
$NVM_NODEJS_ORG_MIRROR: ''
$NVM_IOJS_ORG_MIRROR: ''
shell version: 'GNU bash, version 5.0.17(1)-release (x86_64-pc-linux-gnu)'
uname -a: 'Linux 4.4.0-19041-Microsoft #488-Microsoft Mon Sep 01 13:43:00 PST 2020 x86_64 x86_64 x86_64 GNU/Linux'
checksum binary: 'sha256sum'
OS version: Ubuntu 20.04.2 LTS
curl: /usr/bin/curl, curl 7.68.0 (x86_64-pc-linux-gnu) libcurl/7.68.0 OpenSSL/1.1.1f zlib/1.2.11 brotli/1.0.7 libidn2/2.2.0 libpsl/0.21.0 (+libidn2/2.2.0) libssh/0.9.3/openssl/zlib nghttp2/1.40.0 librtmp/2.3
wget: /usr/bin/wget, GNU Wget 1.20.3 built on linux-gnu.
git: /usr/bin/git, git version 2.25.1
grep: /usr/bin/grep (grep --color=auto), grep (GNU grep) 3.4
awk: /usr/bin/awk, GNU Awk 5.0.1, API: 2.0 (GNU MPFR 4.0.2, GNU MP 6.2.0)
sed: /usr/bin/sed, sed (GNU sed) 4.7
cut: /usr/bin/cut, cut (GNU coreutils) 8.30
basename: /usr/bin/basename, basename (GNU coreutils) 8.30
rm: /usr/bin/rm, rm (GNU coreutils) 8.30
mkdir: /usr/bin/mkdir, mkdir (GNU coreutils) 8.30
xargs: /usr/bin/xargs, xargs (GNU findutils) 4.7.0
nvm current: none
which node:
which iojs:
which npm: /mnt/c/Program Files/nodejs//npm
: not foundget prefix: /mnt/c/Program Files/nodejs/npm: 3:
: not foundram Files/nodejs/npm: 5:
/mnt/c/Program Files/nodejs/npm: 6: Syntax error: word unexpected (expecting "in")
: not found: /mnt/c/Program Files/nodejs/npm: 3:
: not foundram Files/nodejs/npm: 5:
/mnt/c/Program Files/nodejs/npm: 6: Syntax error: word unexpected (expecting "in")

nvm ls output:

$ nvm ls
       v14.16.1
iojs -> N/A (default)
unstable -> N/A (default)
node -> stable (-> v14.16.1) (default)
stable -> 14.16 (-> v14.16.1) (default)
lts/* -> lts/fermium (-> v14.16.1)
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.1 (-> N/A)
lts/fermium -> v14.16.1

How did you install nvm?

$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash

What steps did you perform?

Run the following command: $ nvm install --lts

What happened?

$ nvm install --lts
Installing latest LTS version.
Downloading and installing node v14.16.1...
Downloading https://nodejs.org/dist/v14.16.1/node-v14.16.1-linux-x64.tar.xz...
################################################################################################################# 100.0%Computing checksum with sha256sum
Checksums matched!
mv: cannot move '/home/<username>/.nvm/.cache/bin/node-v14.16.1-linux-x64/files/lib' to '/home/<username>/.nvm/versions/node/v14.16.1/lib': Permission denied
Binary download failed, trying source.
Detected that you have 4 CPU core(s)
Running with 3 threads to speed up the build
Downloading https://nodejs.org/dist/v14.16.1/node-v14.16.1.tar.xz...
################################################################################################################# 100.0%Computing checksum with sha256sum
Checksums matched!
$>./configure --prefix=/home/<username>/.nvm/versions/node/v14.16.1 <
Node.js configure: Found Python 3.8.5...
WARNING: failed to autodetect C++ compiler version (CXX=g++)
WARNING: failed to autodetect C compiler version (CC=gcc)
ERROR: No acceptable C compiler found!

       Please make sure you have a C compiler installed on your system and/or
       consider adjusting the CC environment variable if you installed
       it in a non-standard prefix.
nvm: install v14.16.1 failed!

What did you expect to happen?

Install normally; Instead I received a few errors, could not move files around in my home directory; Permission Denied; then Binary download failed, then trying source; but it appears I did not have any C/C++ compilers installed;

Is there anything in any of your profile files that modifies the PATH?

Dont know, don’t care, don’t understand Linux/Unix; just expected it to work, else I am ditching nvm and going back to plain node / npm;

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Comments: 16 (6 by maintainers)

Most upvoted comments

I had the same problem on a real fresh Ubuntu 20.04, and it was for the same reason as in this SO answer: https://stackoverflow.com/a/67590451/1663736

Turns out the problem was with curl and that I had installed it with snap instead of regular apt install curl.

After removing curl from snap and reinstalling it with apt, I could nvm install without the OP error.

I can confirm this. Snap and apt versions are not the same.

The latest versions of curl are different on snap and apt (snap 7.76.1, apt 7.68.0). Not sure where’s the issue exactly, but hopefully this will point you in the right direction.

EDIT: Not sure if the issue is actually in nvm. Before I installed nvm and before I’ve tried to install Node using the --lts flag, I was installing ZSH or something using curl and it worked. This means it had write permissions in the $HOME directory.

EDIT 2: I’m on Ubuntu 20.04.2 LTS.