Installing Ruby 2.1.1 on Ubuntu 14.04 x86_64

UPDATE: As pointed out in the comments, readline was still not actually installing. As of this update, you can install Ruby 2.1.2 instead of 2.1.1 without the need to configure readline.

I was trying to install ruby on the newly released Ubuntu 14.04 and I was running into some issues with readline.

The error looked something like

readline.c:1977:26: error: ‘Function’ undeclared (first use in this function) rl_pre_input_hook = (Function *)readline_pre_input_hook; ^

The solution is to configure ruby with our lib_readline.so

## Install ruby

sudo apt-get install openssl libreadline-dev curl zlib1g zlib1g-dev libssl-dev libyaml-dev libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison libcurl4-openssl-dev

Grab the source from http://www.ruby-lang.org/en/downloads/

cd && mkdir srcs && cd srcs
wget http://cache.ruby-lang.org/pub/ruby/2.1/ruby-2.1.1.tar.gz
tar xzfv ruby-2.1.1.tar.gz
cd ruby-2.1.1
./configure –with-readline-dir=/usr/lib/x86_64-linux-gnu/libreadline.so
sudo make && sudo make install

NOTE: make sure the ./configure – -with-readline-dir has two dashes. For some reason WP is stripping that.

$$Profit$$

Comments

    David |

    Genius.

    madaray |

    Did this actually enable readline? For me it fixed the readline error by no longer finding readline so rails console doesn’t work.

    madaray |

    including this sed before ./ configure fixed it for me:

    link to linuxfromscratch.org

    Robert Reiz |

    This doesn’t work for me. I’m getting the error message:

    “configure: error: invalid variable name: `–with-readline-dir’”

    Tom Bortels |

    It looks like a “–” (two hyphens) got mangled by the blog software into some weirdo not-a-hyphen dash character in the configure line. If you replace “–with-readline-dir” with “–with-readline-dir” (if this reply gets mangled the same way – yeah, two hyphens).

    Tom Bortels |

    Oh, and yeah – this works because it apparently breaks readline:

    Failed to configure readline. It will not be installed.

    Chris |

    Hi there, for testing purposes I actually need to install 2.1.1.
    I’m really new to Linux and Ruby, so yea! Anyway, would I need to alter the commands at all since I’m trying to install 2.1.1 using RBENV?

    creatives infotech |

    Great Post,
    I want to install Ruby on RadHat.
    Should I follow the same steps ?