Introduction
In this blog post we will talk about how to install ruby on rails on ubuntu or kali linux. We will use RVM as its really easy to manage multiple ruby environments. Follow steps below to simply install the setup through command line.
Installing Ruby using RVM
Ruby Version Manager is a command-line tool which allows you to easily install, manage, and work with multiple ruby environments from interpreters to sets of gems. Firstly, update all your packages using the command below,
sudo apt-get update
Install GPG keys used for verification of installation package.
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
Install rvm with ruby using the command below,
\curl -sSL https://get.rvm.io | bash -s stable --ruby --ignore-dotfiles
Installing Rails Server
Now, let’s install the rails server using rvm.
\curl -sSL https://get.rvm.io | bash -s stable --rails
Alternatively, you can also install rails using gem
command
gem install rails 5
Let’s refresh the configuration using the command below,
source /usr/local/rvm/scripts/rvm
To reinstall ruby, you can use this command,
rvm reinstall ruby 2.6.0
Setting up the path and verify installation
which ruby
Sometimes the path doesn’t gets updated so its better we update the path in .bashrc
file. Add this path (bashrc located at ~ directory) as shown below and save & close it.
Refresh the path using source command, source ~/.bashrc
Let’s verify the installation using the command below,
ruby --version
rails -v
Switching Ruby versions using RVM
You can always switch between ruby version easily using RVM depending on what is installed on your system, In my case I already have two versions viz; 2.5.3
and 2.6.0
use the command below to switch to 2.5.3
rvm use ruby 2.5.3
As you can see in the screenshot below, I switched from version 2.6 to 2.5
In the next blog post we will talk about how to install ruby-mine on linux, which is the best IDE for web development using ruby on rails. Please keep checking goacademy for more engaging blogposts.