public
Last active

Directions on installing chruby, ruby, ruby-build, and bundler.

  • Download Gist
Cocoapods Environment.md
Markdown

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 https://raw.github.com/Homebrew/homebrew/go/install)"

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/chruby.sh
source /usr/local/opt/chruby/share/chruby/auto.sh

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.

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.