Schniz / fnm

🚀 Fast and simple Node.js version manager, built in Rust
https://fnm.vercel.app
GNU General Public License v3.0
16.45k stars 419 forks source link

Unable to download tar.xz file #1088

Open ByLCY opened 5 months ago

ByLCY commented 5 months ago

I want to download node v0.10.36, but there is no node-v0.10.36-darwin-x64.tar.xz file at https://nodejs.org/dist only node-v0.10.36-darwin-x64.tar.gz.

Would like to be able to specify fnm whether to download a .tar.xz file or a .tar.gz file.

image

RUST_LOG=debug fnm install 0.10.36

Installing Node v0.10.36 (x64)
[2024-01-08T09:02:50Z DEBUG fnm::directory_portal] Created a temp directory in "/Users/xxx/Library/Application Support/fnm/node-versions/.downloads/.tmpX2Gx8P"
[2024-01-08T09:02:50Z DEBUG fnm::downloader] Going to call for https://nodejs.org/dist/v0.10.36/node-v0.10.36-darwin-x64.tar.xz
[2024-01-08T09:02:50Z DEBUG reqwest::connect] starting new connection: https://nodejs.org/
[2024-01-08T09:02:50Z DEBUG rustls::client::hs] No cached session for DnsName("nodejs.org")
[2024-01-08T09:02:50Z DEBUG rustls::client::hs] Not resuming any session
[2024-01-08T09:02:50Z DEBUG rustls::client::hs] Using ciphersuite TLS13_AES_256_GCM_SHA384
[2024-01-08T09:02:50Z DEBUG rustls::client::tls13] Not resuming
[2024-01-08T09:02:50Z DEBUG rustls::client::tls13] TLS1.3 encrypted extensions: [ServerNameAck, Protocols([ProtocolName(6832)])]
[2024-01-08T09:02:50Z DEBUG rustls::client::hs] ALPN protocol is Some(b"h2")
error: Can't download the requested binary: v0.10.36 for x64 not found upstream.
You can `fnm ls-remote` to see available versions or try a different `--arch`.
killjoy1221 commented 2 months ago

I experience a similar issue. My node mirror doesn't provide .tar.xz downloads, even for the latest version. When using nvm, I can get around this by patching nvm_supports_xz() { return 1; } function in my bashrc to force it to download the .tar.gz file. I obviously can't do that with fnm.

Ideally, this function would need to return multiple URLs in order of preference (configurable?). i.e. xz -> gz https://github.com/Schniz/fnm/blob/a5a497b7e2c4cc615fedf366f9eeab4e322443ed/src/downloader.rs#L38-L45