Skip to main content
2 of 2
version verification command
Lucio
  • 1.3k
  • 1
  • 13
  • 16

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.

Lucio
  • 1.3k
  • 1
  • 13
  • 16