Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Directions on installing chruby, ruby, ruby-build, and bundler.

Setting up a good cocoapods environment

Before you start

Make sure that you have the latest version of Xcode installed from the Mac App Store, and that you have the command line tools installed. To install the command line tools, open Xcode, click Xcode->Preferences->Downloads->Command Line Tools

Install brew if needed.

ruby -e "$(curl -fsSL"

Install ruby-build.

brew install ruby-build

Install wget if needed.

brew install wget

Install chruby.

brew install chruby

Add the following to the ~/.bashrc or ~/.zshrc or ~/.bash_profile file:

source /usr/local/opt/chruby/share/chruby/
source /usr/local/opt/chruby/share/chruby/

Install desired rubies.

At this time, I'd recommend 1.9.3 (latest patch) and 2.0.0 (latest patch). In this example, we're using 1.9.3-p448 and 2.0.0-p247.

# Make ~/.rubies folder if it doesn't exist
mkdir ~/.rubies
# Get list of latest version of ruby
ruby-build --definitions
# Install latests versions of 1.9.3 and 2.0.0
# If you want other versions feel free to go to town
ruby-build 1.9.3-p448 ~/.rubies/1.9.3-p448
ruby-build 2.0.0-p247 ~/.rubies/2.0.0-p247

To set a default ruby to be used, add the following to the to the ~/.bashrc or ~/.zshrc or ~/.bash_profile.

chruby 1.9.3

you don't have to include the patch number, the latest will always be used. From now on you can use the command chruby 1.9.3 (or whichever version) to change the version of ruby used. If a directory has a .ruby-version file in it, the version of ruby in that file will be used. Example contents of a .ruby-version file would be 1.9.3.

After completing these steps, make sure to source ~/.bash_profile or source ~/.bashrc or source ~/.zshrc so the changes will be applied to your current terminal session.

Install bundler.

For every version of ruby installed, be sure to gem install bundler. for example:

chruby 1.9.3
gem install bundler
chruby 2.0.0
gem install bundler

Bundler is used during the build process to install the correct version of cocoapods specified in the Gemfile in the project directory.


This comment has been minimized.

Copy link

@justanton justanton commented Oct 8, 2016

hi! do you know if it is possible to update Ruby version by using chruby?


This comment has been minimized.

Copy link

@mallyvai mallyvai commented May 13, 2017

@justanton All chruby does is change rubies (hence chruby). It will alert you if the ruby version is out of date, but you'll need to explicitly install the ruby version yourself. Take a look at ruby-install if you want a utility that focuses on installing rubies in a clean way!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment