Setup Ruby 2.3 on Ubuntu 14.04 Trusty Tahr
5 marzo, 2021 por
Setup Ruby 2.3 on Ubuntu 14.04 Trusty Tahr
Administrator
| Sin comentarios aún


Choose the version of Ruby you want to install:

The first step is to install some dependencies for Ruby.

sudo apt-get update
sudo apt-get install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties libffi-dev

Next we’re going to be installing Ruby using one of three methods. Each have their own benefits, most people prefer using rbenv these days, but if you’re familiar with rvm you can follow those steps as well. I’ve included instructions for installing from source as well, but in general, you’ll want to choose either rbenv or rvm.

Choose one method. Some of these conflict with each other, so choose the one that sounds the most interesting to you, or go with my suggestion, rbenv.

Installing with rbenv is a simple two step process. First you install rbenv, and then ruby-build:

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

git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc
exec $SHELL

rbenv install 2.3.1
rbenv global 2.3.1
ruby -v

The last step is to install Bundler

gem install bundler

rbenv users need to run rbenv rehash after installing bundler.

 


—————————————————

 

apt-get install ruby2.2 does give you a ruby executable – it’s just called ruby2.2. Gem and irb are the same (i.e. gem2.2 install bundler will work, irb2.2 will give you an irb prompt.)

This is normal in Ubuntu and the alternatives system generally means you don’t have to care about it, but for whatever reason ruby isn’t managed by alternatives in Ubuntu. But we can make it:

sudo update-alternatives --install /usr/bin/ruby ruby /usr/bin/ruby2.2 400 \
 --slave /usr/bin/rake rake /usr/bin/rake2.2 \
 --slave /usr/bin/ri ri /usr/bin/ri2.2 \
 --slave /usr/bin/rdoc rdoc /usr/bin/rdoc2.2 \
 --slave /usr/bin/gem gem /usr/bin/gem2.2 \
 --slave /usr/bin/irb irb /usr/bin/irb2.2 \
 --slave /usr/share/man/man1/ruby.1.gz ruby.1.gz /usr/share/man/man1/ruby2.2.1.gz \
 --slave /usr/share/man/man1/rake.1.gz rake.1.gz /usr/share/man/man1/rake2.2.1.gz \
 --slave /usr/share/man/man1/ri.1.gz ri.1.gz /usr/share/man/man1/ri2.2.1.gz \
 --slave /usr/share/man/man1/rdoc.1.gz rdoc.1.gz /usr/share/man/man1/rdoc2.2.1.gz \
 --slave /usr/share/man/man1/gem.1.gz gem.1.gz /usr/share/man/man1/gem2.2.1.gz \
 --slave /usr/share/man/man1/irb.1.gz irb.1.gz /usr/share/man/man1/irb2.2.1.gz

Running this will register ruby with the alternatives system and, as there’s only one choice, set ruby 2.2 as default. This will create symlinks and let you use ruby/gem/ etc. without adding 2.2 on the end.

This is a slightly updated version of instructions found at https://leonard.io/blog/2012/05/installing-ruby-1-9-3-on-ubuntu-12-04-precise-pengolin/

 

Identificarse dejar un comentario