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

Version 0.40.0, command nvm install fails when $NVM_DIR path contains spaces #3411

Closed
thevindu-w opened this issue Aug 14, 2024 · 2 comments
Closed

Comments

@thevindu-w
Copy link

thevindu-w commented Aug 14, 2024

Operating system and version:

Should affect all supported operating systems. Tested on,

  • Windows 10 (using Git bash)
  • Linux Mint 20.1

nvm debug output:

nvm --version: v0.40.0
$SHELL: /bin/bash
$SHLVL: 1
whoami: 'user'
${HOME}: /home/user
${NVM_DIR}: '${HOME}/test dir/nvm'
${PATH}: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/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 5.4.0-58-generic #64-Ubuntu SMP Wed Dec 9 08:16:25 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux'
checksum binary: 'sha256sum'
OS version: Linux Mint 20.1 Ulyssa  
awk: /usr/bin/awk, GNU Awk 5.0.1, API: 2.0 (GNU MPFR 4.0.2, GNU MP 6.2.0)
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
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: 
npm config get prefix: 
Command 'npm' not found, but can be installed with:

sudo apt install npm
npm root -g:

nvm ls output:

            N/A
iojs -> N/A (default)
node -> stable (-> N/A) (default)
unstable -> N/A (default)
lts/* -> lts/iron (-> 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.3 (-> N/A)
lts/gallium -> v16.20.2 (-> N/A)
lts/hydrogen -> v18.20.4 (-> N/A)
lts/iron -> v20.16.0 (-> N/A)

How did you install nvm?

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

What steps did you perform?

  • On Windows,

    1. Created a user account containing a space in the username. (Username: John Doe)
    2. Install nvm from Git bash
    3. Opened a new shell (to reload .bashrc)
    4. Tried to install node v20.16.0 using the command nvm install 20.16.0 (This node version exists and this command works on nvm v0.39.7)
  • On Linux,

    1. Set the environment variable $XDG_CONFIG_HOME to /home/user/test dir which is an existing empty directory in the user's home with a space in its path. The current user has read, write, and execute permissions for this test dir directory.
    2. Install nvm using the command mentioned above (using curl)
    3. Opened a new shell (to reload .bashrc)
    4. Tried to install node v20.16.0 using the command nvm install 20.16.0

What happened?

On both operating systems, nvm installation (using curl) succeeded.

However, on both systems, nvm install 20.16.0 command failed with the following error. (The same command works properly with nvm version 0.39.7. Please see the Additional Details section at the bottom)

  • On Windows,

    Downloading and installing node v20.16.0...
    Downloading https://nodejs.org/dist/v20.16.0/node-v20.16.0-win-x64.zip...
    Warning: Failed to create the file C:/Users/John: Permission denied
    curl: (23) Failure writing output to destination
    
    curl: (6) Could not resolve host: Doe
    
    Binary download from https://nodejs.org/dist/v20.16.0/node-v20.16.0-win-x64.zip failed, trying source.
    grep: /c/Users/John Doe/.nvm/.cache/bin/node-v20.16.0-win-x64/node-v20.16.0-win-x64.zip: No such file or directory
    Provided file to checksum does not exist.
    Binary download failed, trying source.
    Can not determine how many core(s) are available, running in single-threaded mode.
    Please report an issue on GitHub to help us make nvm run faster on your computer!
    Installing from source on non-WSL Windows is not supported
    
  • On Linux,

    Downloading and installing node v20.16.0...
    Downloading https://nodejs.org/dist/v20.16.0/node-v20.16.0-linux-x64.tar.xz...
    ##################################################################### 100.0%curl: (22) The requested URL returned error: 416
    
    ##################################################################### 100.0%curl: (6) Could not resolve host: dir
    
    Binary download from https://nodejs.org/dist/v20.16.0/node-v20.16.0-linux-x64.tar.xz failed, trying source.
    grep: /home/user/test dir/nvm/.cache/bin/node-v20.16.0-linux-x64/node-v20.16.0-linux-x64.tar.xz: No such file or directory
    Provided file to checksum does not exist.
    Binary download failed, trying source.
    Downloading https://nodejs.org/dist/v20.16.0/node-v20.16.0.tar.xz...
    ##################################################################### 100.0%curl: (22) The requested URL returned error: 416
    
    ##################################################################### 100.0%curl: (6) Could not resolve host: dir
    
    Binary download from https://nodejs.org/dist/v20.16.0/node-v20.16.0.tar.xz failed, trying source.
    grep: /home/user/test dir/nvm/.cache/src/node-v20.16.0/node-v20.16.0.tar.xz: No such file or directory
    Provided file to checksum does not exist.
    

What did you expect to happen?

To install node without an error.

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

no

Additional Details

  • This error does not occur when $NVM_DIR does not contain spaces on both operating systems, under the same conditions except that $NVM_DIR is set to a directory whose path does not contain spaces (ex: on Windows with username JohnDoe, and on Linux with $XDG_CONFIG_HOME set to /home/user/test_dir) (in nvm versions 0.40.0 and 0.39.7)
  • This error does not occur with nvm version 0.39.7 on both operating systems, even with spaces in $NVM_DIR path, using the same commands, environment variables, node version, user account, and directories.
@ljharb
Copy link
Member

ljharb commented Aug 15, 2024

Thanks; we must be missing some quotes somewhere.

@ljharb
Copy link
Member

ljharb commented Aug 15, 2024

-    curl --fail ${CURL_COMPRESSED_FLAG:-} -q "$@"
+    eval "curl -q --fail ${CURL_COMPRESSED_FLAG:-} ${CURL_HEADER_FLAG:-} $*"

i think this diff (from #3380) may be the cause. Looking into it further.

@ljharb ljharb closed this as completed in 0ce8f5a Aug 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants