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

nvm install can throw "Invalid redirection target" #140

Closed deleteme closed 3 years ago

deleteme commented 3 years ago

I encountered the following error when running nvm install.

~/.config/fish/functions/_nvm_index_update.fish (line 7): Invalid redirection target:
    ' >$index.temp 2>/dev/null && command mv $index.temp $index && return
      ^
in function '_nvm_index_update'
    called on line 32 of file ~/.config/fish/functions/nvm.fish
in function 'nvm' with arguments 'install'
usage: mv [-f | -i | -n] [-v] source target
       mv [-f | -i | -n] [-v] source ... directory
nvm: Invalid index or unavailable host: ""

I found these two related issues #130 and #139 but since I also experienced the error I figured I could track down some reproduction steps.

In Shell 1

  1. curl -sL https://git.io/fisher | source && fisher install jorgebucaran/fisher
  2. fisher install jorgebucaran/nvm.fish

In Shell 2

  1. nvm
  2. nvm install

The attached video demonstrates how to reproduce the bug:

https://user-images.githubusercontent.com/9389/108633557-b3906d00-7429-11eb-838f-d43f92cde11c.mov

The error doesn't happen in new shells. When I noticed that nvm worked in a previously open shell, I assumed that nvm install would work too.

jorgebucaran commented 3 years ago

Fixed by making nvm_data and nvm_mirror universally scoped, so that they're immediately available to all running sessions after installing the plugin. Thank you! 💯