Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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`
@dmittakarin8

This comment has been minimized.

Copy link

dmittakarin8 commented Jul 13, 2012

Couldn't get set-default or set-local to work. Found the following information:

set-default and set-local are deprecated as of 0.2.0. The new commands are global and local, respectively.

@EMart86

This comment has been minimized.

Copy link

EMart86 commented Oct 14, 2019

@sstephenson I've updated this script to use the newest rbenv comands

# 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 local 2.6.4
ruby --version     # 2.6.4

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

# Set a per-project Ruby version
cd ~/myapp
rbenv local 2.6.4
ruby --version     # 2.6.4

# 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`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.