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 Ruby 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 rbenv-default-gems instructions

brew install rbenv-default-gems

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 2.4.3 (latest patch). In this example, we're using 2.4.3.

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

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

chruby 2.4.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 2.4.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 2.4.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 2.4.3
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.

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.