Skip to content

Latest commit

 

History

History
50 lines (36 loc) · 1.8 KB

setup_rbenv.md

File metadata and controls

50 lines (36 loc) · 1.8 KB

##Installing rbenv on Mac

Why version control Ruby?

Out-of-date programmer Ollie uses Ruby 1.9.

Ollie is coding one day in an old project and realizes there's a really cool method he wants to use (for example, #to_h to turn an object into a hash).

But Ruby 1.9 doesn't have #to_h! Ruby 2.0 has #to_h.

Wouldn't it be great if Ollie could switch between ruby versions easily? What if Ollie has tons of different projects using different ruby versions?

Enter rbenv

rbenv keeps track of which version of Ruby you're using.

For Mac OS X:

  1. Open terminal
  2. First we want to make sure we don't have another ruby version manager on our computer (like rvm). Copy, paste, and run the following, one line at a time:
  • sudo rvm implode
    • If it says sudo: rvm: command not found, that's fine.
  • sudo rm -rf ~/.rvm
  • brew ls --versions rbenv
  1. If nothing shows up after you run "brew ls --versions rbenv", copy, paste, and run the following:
  • brew install rbenv
  • brew install ruby-build
  1. Copy, paste, and run:
  • atom ~/.bash_profile
    • If this doesn't work, you probably haven't ever created your bash profile. Go ahead and make this file using touch ~/.bash_profile
  1. In the text editor:
  • Search (command+F) for "rvm", and delete any lines that have it.
  • Copy and paste the following at the bottom:
  export PATH="$HOME/.rbenv/bin:$PATH"
  if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi

  • Save and quit.
  1. Copy, paste, and run:
  • rbenv install 2.1.2
  • rbenv global 2.1.2

Try running a ruby program to test!