Installing software: Ruby

A simple guide

Ruby is a programming language that has become popular after DHH has created a web framework with it, Rails. It is the first robust framework I used for development, but since then I have switched to different tools.

However, even though I rarely use it, there a lot of modern web development tools that rely on it. For example in order to use Sass, a css compiler, you need ruby. Ruby runs a plugins ecosystem commonly referred as gems. A few popular ones I used are capistrano, mustache, or Chef.

Since I work as a contractor, I often have to install a bunch of different tools based on the job. So here is how you install Ruby.

Ruby on Windows

Installing Ruby on windows is farely straight forward. Head to the Rubyinstaller.org and grab the latest copy of Ruby. (2.3.0 as I am writing). Run the installer and you are done.

Ruby installer on Windows 10

To make sure it works, open the command line and type the following:

> ruby -v
ruby 2.3.0p0 (2015-12-25 revision 53290) [x64-mingw32]

The current version installed will be displayed.

Ruby on Linux (Ubuntu)

On Linux it does require a little more work. Let's start first with installing the dependencies.

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

We will use rbenv to install ruby. It is a version management tool for ruby. In other words, it allows you to install different versions of ruby on the same machine, you can have different projects that run different versions of ruby on the same machine.

Let's start by setting up rbenv in your user folder. (~/)

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

Next will be the ruby installer plugin:

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

Now we can install the specific version of ruby that we want and set it to be the default. As of writing this, the stable linux version is 2.3.1

rbenv install 2.3.1
rbenv global 2.3.1

Note: the install command may take a little while and doesn't really give you feedback. But be patient, it is working.

The last step will be to check that ruby is correctly installed.

$ ruby -v
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-linux]

Now you can install the gems you need for your project.

gem install bundler
gem install sass

References


Comments

There are no comments added yet.

Let's hear your thoughts

For my eyes only