How do I install and use a new version of Ruby on DEV@cloud OS X slaves?

Issue

DEV@cloud OS X slaves are using [OS X 10.8 (Mountain Lion)][OS X 10.8 _Mountain Lion] which provide by default only Ruby 1.8.7

Environment

Resolution

OS X slaves are providing [Homebrew][] which allows you to install various packages.

This guide explains how to use it to install [rbenv][] to select the ruby runtime you want to use.

Add a “Execute shell” build step with this content

#!/bin/bash -eu

# Let's install rebenv using homebrew
brew update
brew install rbenv
brew install rbenv-gem-rehash
brew install ruby-build
eval "$(rbenv init -)"

# By default we have only the default ruby
rbenv versions
ruby --version

# list all available versions:
rbenv install -l

# Let's install Ruby 2.0.0
rbenv install 2.0.0-p247
rbenv rehash

# Let's activate it
rbenv global 2.0.0-p247
rbenv versions
ruby --version

# Let's install a gem
gem update --system
gem install --user-install xcodeproj

And you’re ready !!

ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-darwin12.5.0]

You can see a demonstration of this setup in this [rbenv-demo][] job 

[OS X 10.8 _Mountain Lion]: https://developer.cloudbees.com/bin/view/Mobile/Mac+OS+in+the+Cloud+-+Machine+Specifications+
[Homebrew]: http://brew.sh
[rbenv]: https://github.com/sstephenson/rbenv
[rbenv-demo]: https://mobile-examples.ci.cloudbees.com/job/iOS/job/rbenv-demo/

Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.