Skip to content

Instantly share code, notes, and snippets.

@jnx
Created October 1, 2011 20:09
Show Gist options
  • Save jnx/1256593 to your computer and use it in GitHub Desktop.
Save jnx/1256593 to your computer and use it in GitHub Desktop.
rbenv install and system wide install on Ubuntu 10.04 LTS.
# Update, upgrade and install development tools:
apt-get update
apt-get -y upgrade
apt-get -y install build-essential
apt-get -y install git-core
# Install rbenv
git clone git://github.com/sstephenson/rbenv.git /usr/local/rbenv
# Add rbenv to the path:
echo '# rbenv setup' > /etc/profile.d/rbenv.sh
echo 'export RBENV_ROOT=/usr/local/rbenv' >> /etc/profile.d/rbenv.sh
echo 'export PATH="$RBENV_ROOT/bin:$PATH"' >> /etc/profile.d/rbenv.sh
echo 'eval "$(rbenv init -)"' >> /etc/profile.d/rbenv.sh
chmod +x /etc/profile.d/rbenv.sh
source /etc/profile.d/rbenv.sh
# Install ruby-build:
pushd /tmp
git clone git://github.com/sstephenson/ruby-build.git
cd ruby-build
./install.sh
popd
# Install Ruby 1.9.2-p290:
rbenv install 1.9.2-p290
rbenv global 1.9.2-p290
# Rehash:
rbenv rehash
# Update, upgrade and install development tools:
apt-get update
apt-get -y upgrade
apt-get -y install build-essential
apt-get -y install git-core
# Install rbenv:
git clone git://github.com/sstephenson/rbenv.git ~/.rbenv
# Add rbenv to the path:
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> .bash_profile
echo 'eval "$(rbenv init -)"' >> .bash_profile
source ~/.bash_profile
# Install ruby-build:
pushd /tmp
git clone git://github.com/sstephenson/ruby-build.git
cd ruby-build
./install.sh
popd
# Install Ruby 1.9.2-p290:
rbenv install 1.9.2-p290
rbenv global 1.9.2-p290
# Rehash:
rbenv rehash
@aiwilliams
Copy link

Note that rbenv-install.sh expects to run with ~ as the working directory.

@kirs
Copy link

kirs commented Sep 15, 2012

Unfortunately your script doesn't work :(

$ gem install bundler
Fetching: bundler-1.2.0.gem (100%)
ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions into the /usr/local/rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1 directory.

$ sudo gem install bundler
sudo: gem: command not found

@kirs
Copy link

kirs commented Sep 15, 2012

Do you plan to fix and update it somehow?

@fogonthedowns
Copy link

Thanks!

@rubyfreak
Copy link

Some comments would be helpful. Like when do I need one script vs the other and of it works on other versions of ubuntu.

@seifsallam
Copy link

Everything is working great until i close the session. I'm using ubuntu 12.04, problem is I have to run source /etc/profile.d/rbenv.sh every time inorder to use rbenv

@lephuongbg
Copy link

@seifsallam, you can add source /etc/profile.d/rbenv.sh to your ~/bash.rc so you don't need to run that line again for each console instance.

@khebbie
Copy link

khebbie commented Feb 22, 2014

You also need sudo apt-get install libssl-dev

@science
Copy link

science commented Dec 18, 2014

Good start on instructions for global installation for rbenv. I'm not a linux expert but I think it's helpful to also set the "gid" bit on rbenv folders to ensure that as new folders are created they inherit from the group:

find /usr/local/rbenv -type d -exec chmod -R g+s '{}' \;

Additionally you are installing ruby-build as a separate installation. It's better to install it as an rbenv plugin:

mkdir -p /usr/local/rbenv/plugins/ruby-build
git clone https://github.com/sstephenson/ruby-build.git /usr/local/rbenv/plugins/ruby-build

Then you should be able to say rbenv install 2.1.5 and get rbenv to do all the work (and configure/rehash itself after).

@elfassy
Copy link

elfassy commented Aug 7, 2015

echo 'eval "$(rbenv init -)"' >> /etc/profile.d/rbenv.sh is causing an endless loop which ends up taking 100% memory on reboot. Anyone else have this problem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment