Development repository for the ruby_build cookbook
Clone or download
Failed to load latest commit information.
.circleci Add CircleCI and Danger (#74) Oct 15, 2018
.delivery Use delivery local instead of rake and add Chefspec Mar 1, 2017
.github Add github templates and lock bot Jul 24, 2018
attributes Fix lint (#72) Oct 10, 2018
libraries Ubuntu 18.04 to use libgdbm5 and libssl1.0-dev (#71) Oct 9, 2018
recipes Update copyright headers Mar 17, 2017
resources Convert to a custom resource May 8, 2018
spec Use delivery local instead of rake and add Chefspec Mar 1, 2017
test Update test to check in Ruby 2.4.4 May 9, 2018
.foodcritic Fix delivery warnings (#57) Jul 28, 2017
.gitignore Add a few more ignores Feb 13, 2017
.kitchen.dokken.yml ignore CHEF-25 as there is not much we can do without breaking users Sep 6, 2018
.kitchen.yml Convert to a custom resource May 8, 2018
.rubocop.yml Add CircleCI and Danger (#74) Oct 15, 2018
.travis.yml allow centos 6 failures (for now) Oct 4, 2017
Berksfile Move to sous-chefs + testing updates (#52) Feb 12, 2017 Release 1.1.0 Apr 7, 2017 Move to sous-chefs + testing updates (#52) Feb 12, 2017 Move to sous-chefs + testing updates (#52) Feb 12, 2017
Dangerfile Add CircleCI and Danger (#74) Oct 15, 2018
Gemfile make travis happier Oct 4, 2017
LICENSE Add license file Jul 18, 2016 Add cookbook version badge May 11, 2017 Move to sous-chefs + testing updates (#52) Feb 12, 2017
chefignore Don't upload policyfile files to the chef server Apr 7, 2017
metadata.rb Convert to a custom resource May 8, 2018

ruby-build Chef Cookbook

Build Status Cookbook Version


Manages the ruby-build framework and its installed Rubies. A lightweight resources and providers (lwrp) is also defined.


Simply include recipe[ruby_build] in your run_list to have ruby-build installed. You will also have access to the ruby_build_ruby resource. See the See Resources and Providers section for more details.



  • Chef 12.1+


The following platforms have been tested with this cookbook, meaning that the recipes and LWRPs run on these platforms without error:

  • ubuntu 12.04+
  • mac_os_x
  • debian 7+
  • freebsd 9+
  • rhel 6+
  • fedora
  • suse 13+

There might be more that work successfully as well, but those are not tested in test kitchen.

Please report any additional platforms so they can be added.


There are no external cookbook dependencies. However, if you are installing JRuby then a Java runtime will need to be installed. The Opscode java cookbook can be used on supported platforms.


Depending on the situation and use case there are several ways to install this cookbook. All the methods listed below assume a tagged version release is the target, but omit the tags to get the head of development.

From Supermarket

To install this cookbook from the Chef Supermarket, use the knife command:

knife cookbook site install ruby_build

Using Berkshelf

Berkshelf is a cookbook dependency manager and development workflow assistant. To install Berkshelf:

cd chef-repo
gem install berkshelf
berks init

To use the Supermarket version:

echo "cookbook 'ruby_build'" >> Berksfile
berks install

Or to reference the Git version:

latest_release=$(curl -s$repo/git/refs/tags \
| ruby -rjson -e '
  j = JSON.parse(;
  puts { |t| t["ref"].split("/").last }.sort.last
cat >> Berksfile <<END_OF_BERKSFILE
cookbook 'ruby_build',
  :git => 'git://$repo.git', :branch => '$latest_release'



Installs the ruby-build codebase and initializes Chef to use the Lightweight Resources and Providers ([LWRPs][lwrp]).



The Git URL which is used to install ruby-build.

The default is "git://".


A specific Git branch/tag/reference to use when installing ruby-build. For example, to pin ruby-build to a specific release:

node['ruby_build']['git_ref'] = "v20111030"

The default is "master".


The default base path for a system-wide installed Ruby. For example, the following resource:

ruby_build_ruby "1.9.3-p0"

will be installed into "#{node['ruby_build']['default_ruby_base_path']}/1.9.3-p0" unless a prefix_path attribute is explicitly set.

The default is "/usr/local/ruby".


Determines how to handle installing updates to the ruby-build framework. There are currently 2 valid values:

  • "none", false, or nil: will not update ruby-build and leave it in its current state.
  • "sync" or true: updates ruby-build to the version specified by the git_ref attribute or the head of the master branch by default.

The default is "none".

Resources and Providers



Action Description Default
install Build and install a Ruby from a definition file. See the ruby-build readme for more details. Yes
reinstall Force a recompiliation of the Ruby from source. The :install action will skip a build if the target install directory already exists.


Attribute Description Default Value
definition Name attribute: the name of a built-in definition or the path to a ruby-build definition file. nil
prefix_path The path to which the Ruby will be installed. nil
user A user which will own the installed Ruby. The default value of nil denotes a system-wide Ruby (root-owned) is being targeted. Note: if specified, the user must already exist. nil
group A group which will own the installed Ruby. The default value of nil denotes a system-wide Ruby (root-owned) is being targeted. Note: if specified, the group must already exist. nil
environment A Hash of additional environment variables such as CONFIGURE_OPTS or RUBY_BUILD_MIRROR_URL. nil


Install Ruby
# See:
ruby_build_ruby "ree-1.8.7-2012.02" do
  environment({ 'CONFIGURE_OPTS' => '--no-tcmalloc' })

ruby_build_ruby "1.9.3-p0" do
  prefix_path "/usr/local/ruby/ruby-1.9.3-p0"

  action      :install

ruby_build_ruby "jruby-1.6.5"

Note: the install action is default, so the second example is more common.

Install A Ruby For A User
ruby_build_ruby "maglev-1.0.0" do
  prefix_path "/home/deploy/.rubies/maglev-1.0.0"
  user        "deploy"
  group       "deploy"
Reinstall Ruby
ruby_build_ruby "rbx-1.2.4" do
  prefix_path "/opt/rbx-1.2.4"

  action      :reinstall

Note: the Ruby will be built whether or not the Ruby exists in the prefix_path directory.

Known Issues

Public work on this cookbook has resumed after a hiatus. Accordingly, some combinations of versions have issues that you have to work around.

  1. Ubuntu 12.04 and rubinius needs an apt repo for LLVM as the build tools rely on LLVM version between 3.0 and 3.5:
apt_repository 'llvm' do
uri ''
distribution 'llvm-toolchain-precise-3.5'
components ['main']
  1. Ubuntu 14.04 and ruby 2.0.0 patch versions <457
  • The readline and openssl extensions have an issue patched in 457

License and Author

Author:: Fletcher Nichol (

Copyright 2011-2016, Fletcher Nichol

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.