Schniz / fnm

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

`fnm use` fails if node version doesn't exist #75

Closed julen closed 5 years ago

julen commented 5 years ago

Similar to #11, running fnm use when no node versions have been installed results in the same unfriendly error message and 125 error code:

$ fnm use
fnm: internal error, uncaught exception:
     Unix.Unix_error(Unix.ENOENT, "opendir", "/Users/<username>/.fnm/node-versions")
     Raised by primitive operation at file "src/unix/lwt_unix.cppo.ml", line 235, characters 14-31
     Re-raised at file "library/Fs.re", line 5, characters 2-441
     Re-raised at file "library/Versions.re", line 38, characters 4-262
     Re-raised at file "library/Versions.re", line 294, characters 2-497
     Re-raised at file "executable/Use.re", line 15, characters 2-1023
     Re-raised at file "src/core/lwt.ml", line 2987, characters 20-29
     Called from file "src/unix/lwt_main.ml", line 26, characters 8-18
     Called from file "cmdliner_term.ml", line 25, characters 19-24
     Called from file "cmdliner.ml", line 116, characters 32-39
$ echo $?
125

As a user I'd expect fnm use to install the version in case it didn't exist before. Please forgive if this is intended as my expectations come from using nvm before 😁; in such case, providing a friendlier message and pointing to fnm install would help.

Schniz commented 5 years ago

Hi @julen and sorry for the inconvenience! Which version are you using? which OS?

image

This is v1.7.1.

I agree that fnm use could install if missing, but I'm not sure everybody's gonna like it, and rather have fnm use --install-if-missing or have some interactivity

julen commented 5 years ago

I'm using v1.6.2 on Mac OS 10.13.6.

I believe the error happens when you have zero node installations handled by fnm. Try removing those versions you have (or moving the ~/.fnm/node-versions/ folder somewhere else for that matter) and you should be able to reproduce the problem.

Schniz commented 5 years ago

Woah, very good. I'm pushing a fix to that! thanks