oky_sabeni
oky_sabeni

Reputation: 7822

Set up PATH correctly for zsh and RVM

I just switched to ZSH and are having issues with RVM. I believe it is related to my PATH. One issue that I have is when I start a new tab in iTerm2, the ruby version switches to 1.9.3 even though the default is 2.0.0. Here is my .zshrc file.

export PATH="/Users/okyretina/.rvm/gems/ruby-2.0.0-p353@iou-web/bin:$PATH:$HOME/.rvm/bin:/Users/okyretina/.rvm/gems/[email protected]/bin:/Users/okyretina/.rvm/gems/ruby-1.9.3-p429@global/bin:/Users/okyretina/.rvm/rubies/ruby-1.9.3-p429/bin:/Users/okyretina/.rvm/bin:/Users/okyretina/bin:/Users/okyretina/xbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/Users/okyretina/phantomjs/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/share/npm/bin"

# load RVM

# insure /usr/local/bin comes before /usr/bin
# PATH="/usr/local/bin:/usr/local/sbin:$PATH"

PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*

# This command should be at the end for it loads the oh-my-zsh.sh script
source $ZSH/oh-my-zsh.sh

my export PATH is very long but I'm not sure which one is no longer needed.

Upvotes: 0

Views: 3122

Answers (2)

Konstantin D.
Konstantin D.

Reputation: 116

Probably my answer won't help you to solve your particular problem but I will try to help you in finding a solution.

Your $PATH is pretty long and it's hard to make sure that the files have a correct order. In zsh you can set $PATH like this (example taken from my config):

typeset -U path

path=(
  /usr/local/{bin,sbin}
  /usr/local/git/bin
  /usr/local/opt/coreutils/libexec/gnubin
  $path
)

As you can see this method much better in terms of readability and it can help you to make sure that the order in $PATH is correct.

Also in your paths you use both "/Users/okyretina/" and $HOME. I think it makes sense to use $HOME in all cases so your paths will look much shorter and it will be easier to read them.

Upvotes: 1

mpapis
mpapis

Reputation: 53158

run:

rvm get stable --auto-dotfiles

it will reorganize your shell initialization files to load rvm in proper places, make sure to read all the output - it does print information and warnings that are important.

Upvotes: 1

Related Questions