Tags

By year

  1. 2018 (2)
  2. 2017 (4)
  3. 2015 (9)

Building and Installing Ruby with rbenv on Ubuntu/EC2

Ruby AWS Ubuntu rbenv

Posted on Jun 16


Below are some excerpts of my command history when I set up the rbenv to install ruby and some gems.

Environment

$ uname -a
Linux xxx 3.13.0-44-generic #73-Ubuntu SMP Tue Dec 16 00:22:43 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

Installing rbenv

sstephenson/rbenv enables to switch Ruby versions in an application-specific manner. It can be installed by cloning the rbenv repository from GitHub. In the following example, rbenv is installed under the home directory.

$ git clone https://github.com/sstephenson/rbenv.git ~/.rbenv
$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
$ echo 'eval "$(rbenv init -)"' >> ~/.bashrc

Installing ruby-build

sstephenson/ruby-build is a plugin for rbenv that builds a specific version of Ruby.

$ git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build

Building and Installing Ruby

On Ubuntu, the following packages are required to build Ruby 1:

$ sudo apt-get install autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm3 libgdbm-dev

The following command installs v2.0.0-p645 and selects it as the global Ruby version:

$ rbenv install 2.0.0-p645
$ rbenv global 2.0.0-p645

Installing rbenv-gemset

The rbenv-gemset plugin enables to set up and maintain application-specific gemsets. It can be installed in the same way as other plugins.

$ git clone git://github.com/jf/rbenv-gemset.git $HOME/.rbenv/plugins/rbenv-gemset

Creating a New Gemset

$ rbenv gemset create 2.0.0-p645 new-gemset

We can specify the newly created gemset in an application directory:

$ cd application-directory
$ echo new-gemset > .rbenv-gemsets

We can confirm the currently active gemset:

$ rbenv gemset active
$ rbenv gemset file

References



2015 My gh-pages