nvm
nvm copied to clipboard
Error when using the Windows version of curl
Operating system and version:
Windows 10
nvm debug output:
nvm --version: v0.39.7
$SHELL: /bin/bash
$SHLVL: 1
whoami: 'MYUSER'
${HOME}: /home/MYUSER
${NVM_DIR}: '${HOME}/.nvm'
${PATH}: ${NVM_DIR}/versions/node/v18.20.4/bin:${HOME}/bin:/cygdrive/c/Program\ Files/Mozilla\ Firefox:/usr/local/bin:/usr/bin:/cygdrive/c/Program Files/Java/jdk1.8.0_202/bin:/cygdrive/c/Program Files (x86)/Common Files/Oracle/Java/javapath:/cygdrive/c/Python312/Scripts:/cygdrive/c/Python312:/cygdrive/c/Program Files (x86)/RSA SecurID Token Common:/cygdrive/c/Program Files/RSA SecurID Token Common:/cygdrive/c/WINDOWS/system32:/cygdrive/c/WINDOWS:/cygdrive/c/WINDOWS/System32/Wbem:/cygdrive/c/WINDOWS/System32/WindowsPowerShell/v1.0:/cygdrive/c/WINDOWS/System32/OpenSSH:/cygdrive/c/Program Files/dotnet:/cygdrive/c/Program Files/nodejs:/cygdrive/c/ProgramData/chocolatey/bin:/cygdrive/c/Oracle/Middleware/modules/org.apache.ant_1.7.1/bin:/cygdrive/c/Users/MYUSER/AppData/Local/Microsoft/WindowsApps:/cygdrive/c/Users/MYUSER/AppData/Local/Programs/Microsoft VS Code/bin:/cygdrive/c/Users/MYUSER/AppData/Roaming/npm:/cygdrive/c/Program Files/JetBrains/IntelliJ IDEA 2024.1.4/bin:${HOME}/Apps/MYAPP/node_modules/.bin:${HOME}/.local/bin
$PREFIX: ''
${NPM_CONFIG_PREFIX}: ''
$NVM_NODEJS_ORG_MIRROR: ''
$NVM_IOJS_ORG_MIRROR: ''
shell version: 'GNU bash, version 5.2.21(1)-release (x86_64-pc-cygwin)'
uname -a: 'CYGWIN_NT-10.0-19045 3.5.3-1.x86_64 2024-04-03 17:25 UTC x86_64 Cygwin'
checksum binary: 'sha256sum'
awk: /usr/bin/awk, GNU Awk 5.3.0, API 4.0, PMA Avon 8-g1, (GNU MPFR 4.2.1, GNU MP 6.3.0)
curl: /usr/bin/curl, curl 8.8.0 (x86_64-pc-cygwin) libcurl/8.8.0 OpenSSL/3.0.14 zlib/1.3.1 brotli/1.1.0 zstd/1.5.6 libidn2/2.3.7 libpsl/0.21.5 libssh2/1.11.0 nghttp2/1.61.0 libgsasl/2.2.1 OpenLDAP/2.6.8
wget: /usr/bin/wget, GNU Wget 1.24.5 built on cygwin.
git: /usr/bin/git, git version 2.45.1
grep: /usr/bin/grep, grep (GNU grep) 3.11
sed: /usr/bin/sed, sed (GNU sed) 4.9
cut: /usr/bin/cut, cut (GNU coreutils) 9.0
basename: /usr/bin/basename, basename (GNU coreutils) 9.0
rm: /usr/bin/rm, rm (GNU coreutils) 9.0
mkdir: /usr/bin/mkdir, mkdir (GNU coreutils) 9.0
xargs: /usr/bin/xargs, xargs (GNU findutils) 4.10.0
nvm current: v18.20.4
which node: ${NVM_DIR}/versions/node/v18.20.4/bin/node
which iojs: which: no iojs in (${NVM_DIR}/versions/node/v18.20.4/bin:${HOME}/bin:/cygdrive/c/Program\ Files/Mozilla\ Firefox:/usr/local/bin:/usr/bin:/cygdrive/c/Program Files/Java/jdk1.8.0_202/bin:/cygdrive/c/Program Files (x86)/Common Files/Oracle/Java/javapath:/cygdrive/c/Python312/Scripts:/cygdrive/c/
Python312:/cygdrive/c/Program Files (x86)/RSA SecurID Token Common:/cygdrive/c/Program Files/RSA SecurID Token Common:/cygdrive/c/WINDOWS/system32:/cygdrive/c/WINDOWS:/cygdrive/c/WINDOWS/System32/Wbem:/cygdrive/c/WINDOWS/System32/WindowsPowerShell/v1.0:/cygdrive/c/WINDOWS/System32/OpenSSH:/cygdrive/c/Pro
gram Files/dotnet:/cygdrive/c/Program Files/nodejs:/cygdrive/c/ProgramData/chocolatey/bin:/cygdrive/c/Oracle/Middleware/modules/org.apache.ant_1.7.1/bin:/cygdrive/c/Users/MYUSER/AppData/Local/Microsoft/WindowsApps:/cygdrive/c/Users/MYUSER/AppData/Local/Programs/Microsoft VS Code/bin:/cygdrive/c/Users/MYUSER/AppData/Roaming/npm:/cygdrive/c/Program Files/JetBrains/IntelliJ IDEA 2024.1.4/bin:${HOME}/Apps/MYAPP/node_modules/.bin:${HOME}/.local/bin)
which npm: ${NVM_DIR}/versions/node/v18.20.4/bin/npm
npm config get prefix: C:\cygwin64\home\MYUSER\.nvm\versions\node\v18.20.4\bin
npm root -g: C:\cygwin64\home\MYUSER\.nvm\versions\node\v18.20.4\bin\node_modules
nvm ls output:
v18.20.4
default -> 18 (-> v18.20.4)
iojs -> N/A (default)
unstable -> N/A (default)
node -> stable (-> v18.20.4) (default)
stable -> 18.20 (-> v18.20.4) (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
lts/iron -> v20.15.1 (-> N/A)
How did you install nvm?
What steps did you perform?
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
nvm install 20
What happened?
In cygwin, the curl command is optional and if it's not installed, cygwin falls back to the windows curl command. The script installs even when using the windows curl. The problem happens later when nvm install <x> is used:
$ nvm install 20
Downloading and installing node v20.15.1...
Downloading https://nodejs.org/dist/v20.15.1/node-v20.15.1-win-x64.zip...
Warning: Failed to open the file
Warning: /home/MYUSER/.nvm/.cache/bin/node-v20.15.1-win-x64/node-v20.15.1-win-
Warning: x64.zip: No such file or directory
curl: (23) Failure writing output to destination, passed 16384 returned 4294967295
Binary download from https://nodejs.org/dist/v20.15.1/node-v20.15.1-win-x64.zip failed, trying source.
grep: /home/MYUSER/.nvm/.cache/bin/node-v20.15.1-win-x64/node-v20.15.1-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
What did you expect to happen?
I expected node v20.15.1 to download and install successfully.
My feature request: I would like the script to fail with a helpful error when using the Windows curl command. Without one, it's difficult to troubleshoot this error due to a couple of red herrings:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bashsucceeds, suggesting that curl isn't the issue.- An arbitrary newline in the curl Warning message (i.e.,
Warning: /home/MYUSER/.nvm/.cache/bin/node-v20.15.1-win-x64/node-v20.15.1-win-) suggests this could be a CRLF/LF line ending issue.
Is there anything in any of your profile files that modifies the PATH?
.bash_profile:
PATH="${HOME}/bin:/cygdrive/c/Program\ Files/Mozilla\ Firefox:${PATH}:/home/MYUSER/.local/bin"
I didn't even know there was a windows version of curl.
If it's possible for nvm to determine that's the version in use - or better, to feature-test for whatever's not working the same as real curl - then nvm can certainly check for that.
Alternatively, if there's a fix we can make that allows it to work in this scenario, that's ideal.
Unfortunately I'm not sure how this could be tested without your precise setup - in CI or on my end.
This wasn't immediately obvious to me so I wanted to add an explanation of the cause. This is the warning:
$ nvm install 20
Downloading and installing node v20.15.1...
Downloading https://nodejs.org/dist/v20.15.1/node-v20.15.1-win-x64.zip...
Warning: Failed to open the file
Warning: /home/MYUSER/.nvm/.cache/bin/node-v20.15.1-win-x64/node-v20.15.1-win-
Warning: x64.zip: No such file or directory
curl: (23) Failure writing output to destination, passed 16384 returned 4294967295
What's happening is cygwin is using Windows's curl command, and it's telling the command to download the file to /home/MYUSER/.nvm/.cache/bin/.... But that's a cygwin path that Windows (and by extension, Windows's curl command) doesn't understand. Windows paths start with a drive letter, e.g., C:\a\b\c\....
if there's a fix we can make that allows it to work in this scenario, that's ideal.
If there were plans to get nvm running on cmd.exe or powershell, I would agree, but in my opinion, it would be better to error early and force the user to use a posix(-like) curl command. I think in most cases, using the Windows curl would be accidental, and attempting to recover from a human error may mislead the user and their understanding of their own environment.
You were okay with either solution, but I am interested in getting a better understanding of your thoughts on the matter, because it may help me level up my philosophy.
I agree with you; the only way just using windows’ curl is viable is if it can reliably convert the Cygwin path to a Windows path, or, if we could use the windows curl to download to a windows temp dir, and then move it to a Cygwin path.
If it can’t be done right, then an early error is indeed best.
Perhaps the cygwin team should make cygwin's impl of curl no longer be optional ? In the meantime though, it would be good for scripts to do a which curl or similar command to confirm that they are not accessing the Windows curl from a bash-like environment.