Question

Short question

How can I get nvm to work with tmux?

Path Problems

As MarkHu surmised in his answer, the problem is related to the PATH. Below is a comparison of the path in bash before entering tmux and after starting tmux. (I replaced each : in the path with a line break to make it easier to compare.)

Bash and tmux PATH comparison

Now I'm curious as to:

  1. Why are /usr/local/sbin and /Users/matthew/bin are duplicated in the path?
  2. Why did /Users/matthew/.nvm/v0.11.5/bin along with /usr/local/sbin and /Users/matthew/bin get moved to the end of the path?

Background

I'm running OS X 10.8.4 Mountain Lion. I installed tmux v1.8 and Node.js using:

brew install tmux
brew install node

I then decided I wanted to manage multiple node version, so I installed nvm using:

curl https://raw.github.com/creationix/nvm/master/install.sh | sh

If I'm not in a tmux session, nvm appears to work correctly. When I start a tmux session though, it finds the Node.js installed by Homebrew instead of using the nvm version. Any thoughts on how to get nvm to work with tmux?

$ which node
/Users/matthew/.nvm/v0.11.5/bin/node
$ tmux
$ which node
/usr/local/bin/node
$ nvm use v0.11.5
Now using node v0.11.5
$ which node
/usr/local/bin/node 
Était-ce utile?

La solution 2

Check your $PATH environment var before and after.

There is a difference between setting it in ~/.bash_profile and ~/.bashrc depending on how you have those configured.

Also, you may want to read https://unix.stackexchange.com/questions/15453/using-environment-variables-in-tmux-conf-files if you think other node.js-related vars may need to be set.

Autres conseils

I just run:

nvm deactivate
nvm use x.x

That seems to work. You can script out the needed version depending on the project you're working on.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top