Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Recommended Ruby Dev Setup

rbenv & Ruby-build + Bundler

Manage ruby installion and environment for a non-fuss and non-headache development on multiple supported Ruby versions.


Manage your Ruby version for your application and global environment.

  • Uses environment variable to maintain so it's easily configurable.
  • Application specific versioning.
  • Doesn't need to be configured in your shell.
  • Works with Ruby versioned Bundler.


Install any ruby version from source that works well with Rbenv

  • Install from command-line (ie can be scripted).
  • Install any version available easily


Most popular way to manage your projects Gems.


Script provided works with zsh. If you're using a different shell, replace anywhere that mentions .zshrc with your shell's config file.

# Pre-requisites to install
apt-get install autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm3 libgdbm-dev
git clone ~/.rbenv
cd ~/.rbenv && src/configure && make -C src
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.zshrc
~/.rbenv/bin/rbenv init

# Following instruction is usually given from the step above; if not may need to consult the output of above
echo 'eval "$(rbenv init -)"' >> ~/.zshrc
# Reload shell
. ~/.zshrc
# Install ruby-build
mkdir -p "$(rbenv root)"/plugins
git clone "$(rbenv root)"/plugins/ruby-build
# Verify rbenv and ruby-build are installed correctly
curl -fsSL | bash

# Install latest ruby and this gives us Rubygems
rbenv install 2.5.0
rbenv rehash
rbenv global 2.5.0

# Install bundler
gem install bundler

## Install rbenv-bundler to make rbenv bundler aware
git clone -- \


# Install a new Ruby version
rbenv install --list
rbenv install 2.3.0

# Run the command below after you install a new version of Ruby, or install a gem that provides commands.
rbenv rehash

# Lists all Ruby versions known to rbenv, and shows an asterisk next to the currently active version.
$ rbenv versions

# Bundle with the correct project's correct version
cd to-ruby-project-with-Gemfile
# Suppose the project uses Ruby version `2.3.0`.
rbenv local 2.3.0
bundle install

# If `rake` is a Bundler-installed gem executable, report its location
# with `rbenv which`. The result should look like
# `${RBENV_ROOT}/versions/2.1.4/lib/ruby/gems/2.1.0/gems/rake-10.3.2
# /bin/rake` instead of `${RBENV_ROOT}/versions/2.1.4/bin/rake`.
rbenv which rake

# Run `rake` without having to type `bundle exec rake`.



cd ~/.rbenv
git pull


cd "$(rbenv root)"/plugins/ruby-build
git pull
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment