May 1, 2016

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
libffi-dev

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

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

git clone https://github.com/rbenv/rbenv-gem-rehash.git ~/.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...
Let's solve foobar
Debugging Matplotlib
Challenge for the 2017
How to install Ruby on Rails in Linux ?
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 ?
Ubuntu system program problem detected[Solved]