Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby Installing a Ruby on Rails Development Environment in OS X

rbenv global does not change ruby version

I ran rbenv global 2.2.1

Then rbenv rehash

Then I ran rbenv global, which returned 2.2.1

So it seemed like I had globally set my ruby version.

But when I run ruby -v

I get ruby 2.0.0p481 (2014-05-08 revision 45883) [universal.x86_64-darwin14]

Which is, of course, not version 2.2.1.

Why isn't the rbenv global sticking?

John O.
John O.
4,680 Points

In a terminal type:

$echo $PATH

Check to see if <your-home-directory>/.rbenv/shims is in your path. If not, you'll need to add it to your path.

To check it temporarily run:

$export PATH="$HOME/.rbenv/shims:$PATH"

then try checking with ruby -v

To make it permanent add the above path export to your .bash_profile (if you're default shell is bash)

I did exactly what John suggested but now any command works I added

export PATH="$HOME/.rbenv/shims:$PATH"

and now any command in my terminal works... now I do not know how to edit the file again, since any command works in the terminal

4 Answers

Ok I fixed this problem very easy, check in minute 5:41 Jason adds something to the file ~/.profile

Well in OSX Yosetime you need to add it to your .bash_profile instead just replace that


Thanks Sebastian!

That fixed it for me in Yosemite

Thumbs up please to my answer =)

I actually found the answer to anyone running El Capitan...

      echo 'if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi' >> ~/.bash_profile 
      source ~/.bash_profile

Notice that there are two >> instead of one.

After checking, double checking, and triple checking to ensure the problem was not related to a syntax error... I did some research. This is the most current and updated method for those running El Capitain... and 2.2.3 is the recommended version of Ruby.

Ok, I'm sitting here with the exact same problem... except that I'm using El Capitan, and the ~/.bash_profile does not execute properly... it leaves my prompt as just a '>' (no '' of course)... and I am forced to close the terminal.

Any help or tips on how to get this to work in El Capitan? Also, I'm installing 2.2.3 since it's the latest stable version and has the security updates from 2.2.

John O.
John O.
4,680 Points

Make a backup copy of your .bash_profile, delete everything in .bash_profile, then add the following line:

if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi

Open up a new shell window and see if the rbenv global command works.

You might have some syntax errors in your current .bash_profile file

I went as far as copy pasting... so there should be no syntax errors. I however did find the answer, and added it here.

It was as simple as >> instead of > after fi'