jorgebucaran / nvm.fish

The Node.js version manager you'll adore, crafted just for Fish
https://git.io/nvm.fish
MIT License
2.08k stars 69 forks source link

Add case for darwin arm64 #148

Closed raulrpearson closed 3 years ago

raulrpearson commented 3 years ago

Fixes #138.

jorgebucaran commented 3 years ago

Thanks, Raúl! Can you explain how this works?

raulrpearson commented 3 years ago

Sure. Without this fix, on my M1 I get the following:

❯ nvm install lts/erbium
Installing Node v12.21.0 lts/erbium
Fetching https://nodejs.org/dist/v12.21.0/node-v12.21.0-darwin-arm64.tar.gz
nvm: Invalid mirror or host unavailable: "https://nodejs.org/dist/v12.21.0/node-v12.21.0-darwin-arm64.tar.gz"

After this fix, I get:

❯ nvm install lts/erbium
Installing Node v12.21.0 lts/erbium
Fetching https://nodejs.org/dist/v12.21.0/node-v12.21.0-darwin-x64.tar.gz
Now using Node v12.21.0 (npm 6.14.11) ~/.local/share/nvm/v12.21.0/bin/node

Basically, this fix is telling the function to use the darwin-x64 binary instead of the darwin-arm64, which doesn't yet exist. I added the os check following @jamesb93's concerns about not messing up the URL generation for users on Linux.

I'm testing by overwriting the nvm.fish file in my ~/.config/fish/functions folder. I tried installing/uninstalling a couple of Node.js versions. Let me know if you need any other explanation or assurance.

I'm also happy to change the code if you want to suggest a different way to solve this.