Repository: nvm
Issue: Error when using the Windows version of curl
Labels: OS: windows,pull request wanted

<!-- Thank you for being interested in nvm! Please help us by filling out the following form if you‘re having trouble. If you have a feature request, or some other question, please feel free to clear out the form. Thanks! -->

#### Operating system and version:
Windows 10

#### `nvm debug` output:
<details>
<!-- do not delete the following blank line -->

```sh
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
```
</details>

#### `nvm ls` output:
<details>
<!-- do not delete the following blank line -->

```sh
       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)
```
</details>

#### How did you install `nvm`?
<!-- (e.g. install script in readme, Homebrew) -->

#### What steps did you perform?
```sh
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: 

```sh
$ 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:

1. `curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash` succeeds, suggesting that curl isn't the issue.
2. 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`?
<!--  (e.g. `.bashrc`, `.bash_profile`, `.zshrc`, etc) -->
`.bash_profile`:
```sh
  PATH="${HOME}/bin:/cygdrive/c/Program\ Files/Mozilla\ Firefox:${PATH}:/home/MYUSER/.local/bin"
```