dimButTries
dimButTries

Reputation: 886

How to switch Ruby versions on macOS using rbenv

I read a few Stack Overflow posts on a similar question, however, I cannot seem to fix my issue.

How do I get ruby --version to match the rbenv version?

rbenv version
2.6.5 (set by /Users/user/rubyonrails/lists/.ruby-version)

ruby --version
ruby 2.6.3p62 (2019-04-16 revision 67580) [universal.x86_64-darwin19]

When I run

rbenv init
# Load rbenv automatically by appending
# the following to ~/.bash_profile:

eval "$(rbenv init -)"

I read a few other questions on Stack Overflow and modified my bash_profile accordingly, however it has not remedied the faulty rbenv init command.

export WORKON_HOME=$HOME/.virtualenvs
export VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python3
export PROJECT_HOME=$HOME/Django
source /usr/local/bin/virtualenvwrapper.sh
eval "$(rbenv init -)"
export PATH="$HOME/.rbenv/bin:$PATH"

Upvotes: 1

Views: 2229

Answers (1)

Dev Renzo
Dev Renzo

Reputation: 76

Only add these lines on your .bashrc

export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"

later use this command $ rbenv install version-ruby

and for switch use $ rbenv global version-ruby

(replace version-ruby for the number of the version.)

Upvotes: 6

Related Questions