How do I set $PATH?

拜拜、爱过 提交于 2019-12-05 13:10:13

Assuming you have your Ruby 2.2 binary in /usr/local/bin, then you definitely do not want this path in front of your /Users/mkeable/.rvm/gems/ruby-2.3.0/bin.

To ensure the former in front of the latter do

export PATH="/usr/local/heroku/bin:$PATH" 
export PATH="$HOME/.rvm/bin:$PATH"

in your .bash_profile.

One additional note - if Ruby 2.2 is indeed inside of /usr/local/bin, that means you may just be able to remove (or temporarily rename) the binary from that path instead of re-arranging your $PATH.

On my mac in ~/.profile I have:

export 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*

In my ~/.bash_profile:

source ~/.profile

After these configurations close your terminals (Cmd + q on a mac) and open it again. Ensure all requirements are installed, RVM works and ruby 2.3.0 is installed:

rvm requirements
rvm info
rvm install ruby-2.3.0

In your project I suggest to save a .rvmrc file in your project root folder:

rvm use ruby-2.3.0

or with a gemset:

rvm use ruby-2.3.0@my_projet_gemset

This way you switch to ruby 2.3.0 (and your gemset) every time you enter the project root folder.

Works great for me.

Putting export PATH="/Users/mkeable/.rvm/gems/ruby-2.3.0/bin:$PATH" in .bash_profile put the correct Ruby binary at the start of the path. Removing source ~/.profile from .bash_profile erased all that doubling I got from echo $PATH. .bashrc is already loaded, so there's no reason to load it a second time.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!