Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default version isn’t activated. #13

Closed
architectcodes opened this issue Jun 2, 2015 · 8 comments

Comments

Projects
None yet
4 participants
@architectcodes
Copy link

commented Jun 2, 2015

As in 7c77e47#commitcomment-11485436:

Even if I nvm alias default … the default version isn’t activated for a new shell.

The original nvm activates default automatically:

To set a default Node version to be used in any new shell, use the alias 'default':
— from creationix/nvm

@passcod

This comment has been minimized.

Copy link
Owner

commented Jun 2, 2015

So, before 7c77e47, there was a line at the end of this file like this:

nvm use default 2>&1 >/dev/null

which took care of setting things up. The problem is that in some cases, if there is no node version installed or no default alias set up, it errors out and prevents nvm-fish-wrapper from being used, see #10 and #11.

The root of the problem, of course, is that while simply sourcing nvm.sh in bash automatically does this setup, sourcing the wrapper just loads a function but doesn't invoke it, so the setup is never done prior to the first use of nvm.

A possible solution could be to find an nvm command which does nothing and always works, but still sets up the default Node version if the alias is set.

An alternative or improvement on this might be to check that there is a default alias set up before trying to run this line. How to do this without invoking nvm in a way that would trigger the above bugs is the challenge.

To investigate:

  • Whether this bug happens on all platforms
  • Whether this bug occurs on platforms that have a system version of node installed already
  • Whether any command will do or if nvm use default has to be used
@ghost

This comment has been minimized.

Copy link

commented Jun 10, 2015

I was experiencing this same bug on Arch Linux without a system version of node. I put this in my config.fish file and put the nvm.fish file in the functions directory. It works, but there is a little delay when opening a terminal due to running the nvm commands.

if test -f ~/.config/fish/functions/nvm.fish
  if test (nvm current) = none -a -n (nvm alias default)
    nvm use default 2>&1 >/dev/null
  end
end
@passcod

This comment has been minimized.

Copy link
Owner

commented Jun 10, 2015

Thanks, @randyschneck, that's quite useful! I'll have to think more about this, maybe see if this snippet can be brought into nvm-wrapper in some way, and optimised so it doesn't cause excessive delays.

@ghost

This comment has been minimized.

Copy link

commented Jun 10, 2015

Wrapping the above in an if status --is-login block solved my slowdown issue. The actual part that was really slow was the nvm use default. Now that is only called from the first login shell and shells spawned from there seem to continue to work without delay. The problem with this solution is that tmux always spawns login shells, so I had to add set-option -g default-command "${SHELL}" to my .tmux.conf so that it doesn't start a login shell for every window/pane to prevent the extra calls to nvm current and nvm alias.

@jadengore

This comment has been minimized.

Copy link

commented Jul 5, 2015

if status --is-login
  if test -f ~/.config/fish/functions/nvm.fish
    if test (nvm current) = none -a -n (nvm alias default)
      nvm use default 2>&1 >/dev/null
    end
  end
end

Does this look good @randyschneck? I was also experiencing the same bug with no system version of node on OS X 10.10.3. So the initial command in 7c77e47 only works if you have already sourced a default for nvm alias, but it will error out if this is not set up?

@passcod

This comment has been minimized.

Copy link
Owner

commented Jul 5, 2015

That's still calling the nvm wrapper three times... i.e. spawning a bash shell and doing some I/O and processing three times. It would be better to build something in the wrapper internals that can run all that without all the overhead multiple times.

@Lordnibbler

This comment has been minimized.

Copy link

commented Aug 15, 2015

Any updates on this issue, or any way I can help?

@passcod

This comment has been minimized.

Copy link
Owner

commented Aug 15, 2015

As mentioned in the readme, this tool is now deprecated in favour of bass.

@passcod passcod closed this Aug 15, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.