rbenv not changing ruby version
Check that PATH contains $HOME/.rbenv/shims
and $HOME/.rbenv/bin
$ env | grep PATH
Also check that you have the following in your ~/.bash_profile if using bash or ~/.zshenv if using zsh
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
NOTE:
Make sure it's the last setting in your ~/.bash_profile . I ran into an issue where I installed a program that updated my .bash_profile and reset PATH.
Finally, make sure your $HOME
folder doesn't have a .ruby-version
file that you may have created by accident if you were to have done $ rbenv local <ruby-version>
in your $HOME
folder. Doing $ rbenv global <ruby-version>
modifies the $HOME/.rbenv/version
file, and the existence of a .ruby-version
file in the $HOME
folder would override the version set by $HOME/.rbenv/version
.
From the docs:
Choosing the Ruby Version
When you execute a shim, rbenv determines which Ruby version to use by reading it from the following sources, in this order:
The RBENV_VERSION environment variable, if specified. You can use the rbenv shell command to set this environment variable in your current shell session.
The first .ruby-version file found by searching the directory of the script you are executing and each of its parent directories until reaching the root of your filesystem.
The first .ruby-version file found by searching the current working directory and each of its parent directories until reaching the root of your filesystem. You can modify the .ruby-version file in the current working directory with the rbenv local command.
The global ~/.rbenv/version file. You can modify this file using the rbenv global command. If the global version file is not present, rbenv assumes you want to use the "system" Ruby—i.e. whatever version would be run if rbenv weren't in your path.
rbenv can't change global ruby version
Did you add the following lines to your ~/.bash_profile
?
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
See: https://github.com/sstephenson/rbenv#installation
rbenv working but ruby version not changing
Restarting my computer resolve the issue.
❯ ruby -v
ruby 2.4.2p198 (2017-09-14 revision 59899) [x86_64-darwin16]
❯ gem -v
2.6.13
I want to change ruby version by rbenv, but I can't reset my 'which ruby'
Ensure there is something like this in your ~/.zshrc
file:
if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi
Why cant I change my ruby version with rbenv?
You probably forgot to set add rbenv's bin
directory early in your $PATH
. Because of this, you are using your system's Ruby instead of the one installed by rbenv.
To ensure rbenv's binaries are added to your PATH, you can add the initialization to your .bash_profile
file (depending on which shell you use and where exactly you installed rbenv to).
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
Please have a look at the installation instructions for rbenv at https://github.com/rbenv/rbenv#installation, esp. point 2.
Related Topics
How to Structure a Layout Template in Haml
Carrierwave Crop Specific Version
Ruby: How to Make a Public Static Method
Ruby: How to Count the Number of Times a String Appears in Another String
Ruby Koan 151 Raising Exceptions
Ruby Concatenate Strings and Add Spaces
Rails: Logging for Code in the Lib Directory
Comparing Times Only, Without Dates
Unit Test in Rails - Model with Paperclip
Passing Param Values to Redirect_To as Querystring in Rails
Ruby: Get All Keys in a Hash (Including Sub Keys)
How to Introspect Things in Ruby
Can't Convert Fixnum to String During Rake Db:Create
How to Get a List of All Tags While Using the Gem 'Acts-As-Taggable-On' in Rails (Not the Counts)
How to Render a Partial in Sinatra View (Haml in Haml)
Convert Unicode into Character with Ruby
Error About Nokogiri While Capistrano Deployment on Ubuntu Server