vadviktor
8/2/2011 - 7:08 PM

Quick guide to installing rbenv

Quick guide to installing rbenv

# Clone rbenv into ~/.rbenv
git clone git@github.com:sstephenson/rbenv.git ~/.rbenv

# Add rbenv to your PATH
# NOTE: rbenv is *NOT* compatible with rvm, so you'll need to 
# remove rvm from your profile if it's present. (This is because
# rvm overrides the `gem` command.)
echo 'export PATH="$HOME/.rbenv/bin:$HOME/.rbenv/shims:$PATH"' >> ~/.bash_profile
exec $SHELL

# Install Ruby versions into ~/.rbenv/versions
# (ruby-build is a convenient way to do this)
cd
git clone git@github.com:sstephenson/ruby-build.git
cd ruby-build
./install.sh
ruby-build 1.8.7-p352 ~/.rbenv/versions/1.8.7-p352
ruby-build 1.9.3-preview1 ~/.rbenv/versions/1.9.3-preview1

# Install shims for all Ruby binaries
rbenv rehash

# Set a default Ruby version
rbenv set-default 1.9.3-preview1
ruby --version     # 1.9.3

# When you install gems with binaries, you need to run `rbenv rehash`
gem install bundler
bundle --version   # command not found
rbenv rehash
bundle --version   # 1.0.15

# Set a per-project Ruby version
cd ~/myapp
rbenv set-local 1.8.7-p352
ruby --version     # 1.8.7

# Other commands:
rbenv prefix       # show the prefix path for the current Ruby version
rbenv version      # show the current Ruby version
rbenv versions     # show all installed Ruby versions
rbenv which irb    # show the full path to a command, like `irb`