May 1, 2016

1 minutes to read

How to install Ruby on Linux

We will be setting up Ruby development environment on Ubuntu 16.04.

Since Ubuntu is one of the easiest linux distribution and is used by many people, we will start with it.

Installing Ruby

Step 1: Install dependencies for Ruby

sudo apt update
sudo apt 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

We will use rbenv for setting up the environment. For this we will have to setup rbenv first.

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

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

git clone ~/.rbenv/plugins/rbenv-gem-rehash

rbenv install 2.3.0
rbenv global 2.3.0
ruby -v

Then we need to install the bundler which is basically a ruby gem.

gem install bundler
rbenv rehash

Now, run which ruby in the terminal to check whether ruby has been installed or not. If ruby is successfully installed then, /home/{username}/.rbenv/shims/ruby will be returned.

You might also like...
Demo for Kirin San
Fixing mysql2 install error
Debugging Matplotlib
Ubuntu system program problem detected[Solved]
Serving Content through Cloudflare network
One liner server command in ruby
Free website using jekyll and free github hosting
How to install Jekyll ?
How to register for GithubEducation Pack ?