nvm icon indicating copy to clipboard operation
nvm copied to clipboard

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

Open joe-oli opened this issue 4 years ago • 16 comments

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;

joe-oli avatar Apr 18 '21 12:04 joe-oli

You’re installing an old version of nvm; can you try the latest one?

ljharb avatar Apr 18 '21 13:04 ljharb

Although oddly enough your debug output suggests it is the latest, so maybe that’s not the problem.

It’s trying to compile node, and you don’t have gcc installed. I’m afraid that if you want a proper Linux node installed, you may need to learn a bit about the os, and get the proper tools installed.

ljharb avatar Apr 18 '21 13:04 ljharb

It’s trying to compile node, and you don’t have gcc installed

Does this nvm repo have binaries available anywhere, or is this the way it's meant to work - everyone must compile from source?

My output shows:

mv: cannot move '/home//.nvm/.cache/bin/node-v14.16.1-linux-x64/files/lib' to '/home//.nvm/versions/node/v14.16.1/lib': Permission denied

Is that legitimate / expected, or am I doing something wrong?

Again my output shows:

Binary download failed, trying source.

Is this meant to happen?

joe-oli avatar Apr 18 '21 15:04 joe-oli

You’re installing an old version of nvm

I typed the v0.35.3 as an example of using curl, but when I actually ran it, I replaced that with the latest version; PS. I followed the instructions on the microsoft page about installing NVM on WSL2; https://docs.microsoft.com/en-us/windows/nodejs/setup-on-wsl2

joe-oli avatar Apr 18 '21 16:04 joe-oli

node prebuilds binaries for many platforms. When yours is one of them, nvm installs that. When it isn’t, then yes, every node user in that scenario builds from source. Usually Linux distros all ship with compilers included; the ones that don’t, users of them have to provide them themselves. You can use apt to install them (implied by the tutorial you linked), but I’d expect them to be there by default already :-/

The double slash suggests that your $HOME has a trailing slash on it, which is incorrect - directories don’t include the trailing slash. I doubt that’s the real issue here tho (but it’s good to fix ASAP)

I also see that you have a windows version of node/npm installed; that shouldn’t conflict at all, but it might be worth trying to remove it first.

The permission denied error means you need to chown/chmod $HOME - you should always have full permissions on every file in there.

ljharb avatar Apr 18 '21 16:04 ljharb

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.

anatoliyarkhipov avatar May 20 '21 17:05 anatoliyarkhipov

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.

burnmaniac avatar May 26 '21 17:05 burnmaniac

Seems like the issue here is that snap's curl is broken, so I'll close this.

ljharb avatar May 26 '21 17:05 ljharb

@ljharb I don't want to be a party breaker, but I would definitely have a closer look at this. Read my edit in https://github.com/nvm-sh/nvm/issues/2492#issuecomment-848975891.

burnmaniac avatar May 26 '21 17:05 burnmaniac

Sure, I can reopen it until we're confident.

ljharb avatar May 26 '21 17:05 ljharb

I can confirm this is an issue in some scenarios but not with curl, since the file is downloaded successfully, but there is some weird permission error when trying to unpack the binary download.

nvm --version: 0.38.0

nvm install 14:

Downloading and installing node v14.17.1...
Local cache found: ${NVM_DIR}/.cache/bin/node-v14.17.1-linux-x64/node-v14.17.1-linux-x64.tar.xz
Checksums match! Using existing downloaded archive ${NVM_DIR}/.cache/bin/node-v14.17.1-linux-x64/node-v14.17.1-linux-x64.tar.xz
mv: cannot move '/home/james.hindman/.nvm/.cache/bin/node-v14.17.1-linux-x64/files/bin' to '/home/james.hindman/.nvm/versions/node/v14.17.1/bin': Permission denied
mv: cannot move '/home/james.hindman/.nvm/.cache/bin/node-v14.17.1-linux-x64/files/include' to '/home/james.hindman/.nvm/versions/node/v14.17.1/include': Permission denied
mv: cannot move '/home/james.hindman/.nvm/.cache/bin/node-v14.17.1-linux-x64/files/lib' to '/home/james.hindman/.nvm/versions/node/v14.17.1/lib': Permission denied
mv: cannot move '/home/james.hindman/.nvm/.cache/bin/node-v14.17.1-linux-x64/files/share' to '/home/james.hindman/.nvm/versions/node/v14.17.1/share': Permission denied
Binary download failed, trying source.

BlissfulDarkness avatar Jun 21 '21 20:06 BlissfulDarkness

@hindmanj can you confirm that your user fully owns $HOME?

ljharb avatar Jun 21 '21 21:06 ljharb

I haven't changed anything, and this is a fresh install of Ubuntu 20.04 inside WSL2, on Win 10 Pro 21H1. This is a 2nd user account, hence the 1001 UID/GID instead of 1000, but that shouldn't matter in the least, since nvm is installed per-user anyway.

stat ~: Access: (0755/drwxr-xr-x) Uid: ( 1001/james.hindman) Gid: ( 1001/james.hindman) stat ~/.nvm: Access: (0755/drwxr-xr-x) Uid: ( 1001/james.hindman) Gid: ( 1001/james.hindman)

The .nvm folder was created by the installer script for the version shown.

BlissfulDarkness avatar Jun 21 '21 23:06 BlissfulDarkness

It looks like the tarball doesn't have a files subfolder inside it, so the mv source path is wrong?

BlissfulDarkness avatar Jun 21 '21 23:06 BlissfulDarkness

sudo apt install gcc g++ the command above could fix this issue

0xUniko avatar Aug 01 '21 03:08 0xUniko

error:

WARNING: failed to autodetect C++ compiler version (CXX=g++)
WARNING: failed to autodetect C compiler version (CC=gcc)
ERROR: No acceptable C compiler found!

Thus, as mentioned by @0xUniko sudo apt install gcc g++

abdennour avatar Jun 03 '23 06:06 abdennour