1

I've been through a couple of tutorials on how to install ruby 2.1.* My system currently has ruby 1.9.3 and I want the latest one. I'm following the following tutorial on how to install it from here: http://ryanbigg.com/2014/10/ubuntu-ruby-ruby-install-chruby-and-you//

So far these are the commands I got up to:

sudo apt-get install build-essential

wget -O ruby-install-0.5.0.tar.gz \
  https://github.com/postmodern/ruby-install/archive/v0.5.0.tar.gz
tar -xzvf ruby-install-0.5.0.tar.gz
cd ruby-install-0.5.0/
sudo make install

ruby-install ruby 2.1.3
DEPENDENCY ERRORS

Once i get to ruby-install ruby 2.1.3, i get hit with this:

>>> Installing ruby 2.1.3 into /opt/rubies/ruby-2.1.3 ...
>>> Installing dependencies for ruby 2.1.3 ...
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package libyaml-dev is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

Package libgdbm-dev is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

Package libncurses5-dev is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

Package libffi-dev is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'libyaml-dev' has no installation candidate
E: Package 'libgdbm-dev' has no installation candidate
E: Unable to locate package libreadline-dev
E: Package 'libncurses5-dev' has no installation candidate
E: Package 'libffi-dev' has no installation candidate
!!! Installing dependencies failed!

Ok, it says i'm missing all these dependencies. How can I just get them to install it so it can stop complaining? Why isn't there a command that just says "okay your missing these dependencies, let me install them for you (yes/no)?

  • About your last question: If your system is missing dependencies at compile time, it is not compiler responsability to install them. – Lucio Jan 6 '15 at 3:31
  • so that means i have to install them one at a time? what if you run into nested dependencies? dependencies that require other dependencies? – Patoshi パトシ Jan 6 '15 at 3:43
  • A backport is probably the best way to do this. See unix.stackexchange.com/q/112157/4671 – Faheem Mitha Jan 6 '15 at 7:57
1

Following are the commands to install Ruby 2.1 in a Debian based system according the the official Ruby Dockerfile. BTW, you can avoid this pain using Docker.

# Update your system packages
apt-get update 

# Install some basic dependencies
# Few of thems aren't needed but won't hurt anyway
apt-get install -y \
    autoconf \
    build-essential \
    imagemagick \
    libbz2-dev \
    libcurl4-openssl-dev \
    libevent-dev \
    libffi-dev \
    libglib2.0-dev \
    libjpeg-dev \
    libmagickcore-dev \
    libmagickwand-dev \
    libmysqlclient-dev \
    libncurses-dev \
    libpq-dev \
    libreadline-dev \
    libsqlite3-dev \
    libssl-dev \
    libxml2-dev \
    libxslt-dev \
    libyaml-dev \
    zlib1g-dev \

apt-get install -y curl procps

RUBY_MAJOR="2.1"
RUBY_VERSION="2.1.5"

apt-get install -y bison ruby

mkdir -p /usr/src/ruby
curl -SL "http://cache.ruby-lang.org/pub/ruby/$RUBY_MAJOR/ruby-$RUBY_VERSION.tar.bz2" | tar -xjC /usr/src/ruby --strip-components=1
cd /usr/src/ruby
autoconf
./configure --disable-install-doc
make -j"$(nproc)"
apt-get purge -y --auto-remove bison ruby
make install
rm -r /usr/src/ruby

GEM_HOME="/usr/local/bundle"
PATH=$PATH:$GEM_HOME/bin
gem install bundler
bundle config --global path "$GEM_HOME"
bundle config --global bin "$GEM_HOME/bin"

As you can imagine, some of the commands will need to be enter in sudo mode.

At this point you should have Ruby 2.1.5 installed. To verify enter ruby -v.

NOTE: I have not tested this so feel free to bring feedback.

  • what happens if you already have an older version of ruby? does it overwrite it? – Patoshi パトシ Jan 6 '15 at 4:13
  • Good question, yes it does. The apt-get install ruby command will fail but the apt-get purge ruby one won't. – Lucio Jan 6 '15 at 4:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.