I installed rbenv from one directory, now I am in another directory and I no longer have the same version of Ruby installed, which I understand is the point of rbenv to have the option of multiple versions of Ruby installed.
I installed rbenv to begin:
brew install rbenv
Now in the following folder ~/Users/steven/xyz/work/
I installed Ruby 2.3.1:
rbenv install 2.3.1
Then I was told to add it to my bash_profile using nano ~/.bash_profile
:
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
Now when I use ruby -v
in ~/Users/steven/xyz/work/
I get ruby 2.3.1p112
which is good.
However, when I jump over to ~/Users/steven/xyz/projects
, ruby -v
gives me ruby 2.0.0p648
which is not good.
So, how do I now get Ruby 2.3.1 in the other folder?
If you use rbenv you can create a ".ruby-version" file using:
rbenv local 2.0.0-p353
which is stored inside the .ruby-version file. Just replace 2.0.0-p353
with your version of Ruby.
You can specify a Ruby version inside gem file if you use RVM:
source "https://rubygems.org"
ruby "2.3.1"
When you switch folders it will load the Ruby specified in the Gemfile. For other engines you can use:
ruby "2.2.2", :engine => "jruby", :engine_version => "9.0.0.0"