Michael Cordell's Blog

Ubuntu 14.04 and Compiling Ruby 2.X

While trying to set up a VPS running Ubuntu 14.04 I was unable to compile Ruby 2.1.1 (which was the current version). I kept running into errors such as:

readline.c:1977:26: error: ‘Function’ undeclared ...

The cause is that Ubuntu 14.04 ships with Readline version 6.3 which apparently breaks builds of Ruby and Python. This issue has been solved for Ruby but will likely be available for Ruby until 2.1.2 . In the interim here is the process for compiling ruby 2.1.1 on Ubuntu 14.04.

Get the tar of the current version and untar it:

curl --progress ftp://ftp.ruby-lang.org/pub/ruby/2.1/ruby-2.1.1.tar.gz | tar xz

Change directories into Ruby source

cd ruby.2.1.1

Download this patch from Mislav Marohnić, a contributor to Ruby Build and github staff member:

sudo curl -O https://gist.githubusercontent.com/mislav/a18b9d7f0dc5b9efc162/raw/563d5c2efb869cafb0c65404d12243822bba2817/readline.patch

Apply the patch:

patch -p0 < readline.patch

Make and Install as usual:

sudo make
sudo make install

Ruby should now be installed for the system.

comments powered by Disqus