January 17th, 2013

System Wide Install With rbenv

This post is going to cover installing rbenv 0.4.0 system wide and is largely taken from the old rbenv wiki page titled “Shared Install of rbenv” which was been taken down at some point.

Installing rbenv

Instead of the usual location of ~/.rbenv for single installs we’ll be installing to /usr/local. You can use a different path if you want, but this is what I prefer.

cd /usr/local
git clone git://github.com/sstephenson/rbenv.git rbenv
chgrp -R staff rbenv
chmod -R g+rwxXs rbenv

Make sure the users that will use rbenv are part of the group you associated with the rbenv folder.

Now we want to add the following code into each users ~/.profile, ~/.bash_profile, or ~/.zshenv depending on the environment. You can also add it in /etc/skel/.profile or /etc/skel/.bash_profile template files that are copied when new users are created.

export RBENV_ROOT=/usr/local/rbenv
export PATH="$RBENV_ROOT/bin:$PATH"
eval "$(rbenv init -)"

Installing ruby-build (optional)

Optionally, you can install the ruby-build plugin to save yourself from building it yourself.

cd /usr/local/rbenv
mkdir plugins
cd plugins
git clone git://github.com/sstephenson/ruby-build.git
chgrp -R staff ruby-build
chmod -R g+rwxs ruby-build

Notes

Now you should have rbenv and optionally ruby-build setup so you can get started installing and using Ruby. This install is the same as the single user install with two exceptions. The global setting applies to all users and single user rbenv installs can “override” the system wide install.

If you have permission issues make sure all the files in the rbenv folder belong to the proper group and that the users trying to use rbenv are also members of the group.