jorgebucaran / nvm.fish

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

nvm install fails if ~/.local/share/nvm/ is missing #161

Closed ghost closed 3 years ago

ghost commented 3 years ago

Hey Jorge

Love nvm.fish, just ran into minor trouble when doing a fresh install on manjaro arch 21.1, fish etc. is up to date.

maybe do a set -l d $HOME/.local/share/nvm; test -d $d; or mkdir -p $d 2>/dev/null on install to make sure ...?

Thanks!

 ~ ↳ nvm install latest
warning: An error occurred while redirecting file '/home/USER/.local/share/nvm/.index.temp'
open: No such file or directory
nvm: Invalid index or unavailable host: "https://nodejs.org/dist"

 ~ ✗  mkdir .local/share/nvm

 ~ ↳  nvm install latest
Installing Node v16.7.0 latest
Fetching https://nodejs.org/dist/v16.7.0/node-v16.7.0-linux-x64.tar.gz
Now using Node v16.7.0 (npm 7.20.3) ~/.local/share/nvm/v16.7.0/bin/node
jorgebucaran commented 3 years ago

Thank you! Maybe a dupe of #154?

Did it work fine when you tried your suggestion?

ghost commented 3 years ago

Ho Jorge! Oh, yes, sorry, see per log above. Created the directory and it ran smoothly. I guess it's related to #154.

Something like that often happens when testing in a non-reproducible environment. I pesonally use a wrapper for any expected dependency (set target (__dir blah)) which returns 1 on permissions error or 0 and the path of the created or existing folder if all is well as an inline substiture for directory variables. Or testing in a docker container, but I try to make sure all external dependencies are more ot less controlled (but bloats the codebase unless you have a DSL for that :-) To summarize: #154 and #161 (this) should both be reproducible in a more or less clean arch (ar at least manjaro) install. Let me know if I can be of further assistance in pinning this down!

jorgebucaran commented 3 years ago

I think we can do as you suggest. If you would like to send me a PR, you can do that, otherwise, I'll try to look into it soon(ish).

tuananh commented 3 years ago

i can confirm the bug with a newly install OS

jorgebucaran commented 3 years ago

If anyone can send me a PR for this, I'll look into it right away.

ghost commented 3 years ago

@jorgebucaran i'm looking forward opening a PR to address this issue, was studying the code and stumbled upon this, i know that it might sound like a dumb question, but even though it's not actually working, in theory, shouldn't it be able fix this? it's recursively creating the ~/.local/share/nvm/$v, or am i missing something?

jorgebucaran commented 3 years ago

My thoughts, exactly. I haven't been able to reproduce this myself.

@qodo-io @tuananh Thoughts?

ghost commented 3 years ago

This happened to me while running a fresh install of Arch on a vm, creating the directory solved the issue, but this got me thinking, it's a bit confusing taking into consideration that in theory it should work, but in practice it doesn't, not sure if it affects all use cases, or only some specific ones

jorgebucaran commented 3 years ago

Did you install nvm.fish using Fisher?

ghost commented 3 years ago

Yep, i strictly followed the instructions on the readme

tuananh commented 3 years ago

i try many distro in the past weeks and this all happens on a freshly installed OS. install using fisher + instructions in nvm.fish readme.

jorgebucaran commented 3 years ago

Does it happen on macOS too?

tuananh commented 3 years ago

Does it happen on macOS too?

can't say. I no longer use macOS

jorgebucaran commented 3 years ago

@qodo-io I was able to reproduce this by deliberately removing $nvm_data, and trying to use nvm install.

That will cause nvm to fail, but you shouldn't be missing $nvm_data as it's created on install: https://github.com/jorgebucaran/nvm.fish/blob/8922519b432140e6eaafbb4dc397505c8da80139/conf.d/nvm.fish#L6

Maybe this happened because you were using an ancient nvm before we had lifecycle events, and got into a situation where you didn't have $nvm_data but nvm installed.

@tuananh $nvm_data must exist after installing nvm. If it doesn't, then your Fish could be broken.

ElijahLynn commented 2 years ago

Thanks for this thread, I just ran into this on Arch, been a loooong time since I used nvm/node on this box. But... I had the AUR nvm installed as well as jorgebucaran/nvm.fish installed with Fisher. I removed the nvm AUR package and then still had to fisher remove jorgebucaran/nvm.fish and then fisher install jorgebucaran/nvm.fish again to get nvm list-remotes to work without throwing this error in the OP.

Thanks!