Installing Rails with RVM on Ubuntu 20.10

Essentials

Ok, let’s make sure the essentials are installed:

sudo apt-get install -y autoconf bison build-essential curl g++ gcc git libffi-dev libgconf-2-4 libgdbm-dev libncurses5-dev libreadline-dev libsqlite3-dev libssl-dev libxi6 libyaml-dev make sqlite3 xvfb zip zlib1g-dev nodejs gnupg2 vim libgmp-dev

Yarn

Now we need to install Yarn:

curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -

echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list

sudo apt update && sudo apt install -y yarn

RUBY VERSION MANAGER (RVM)

Time to install RVM, but first we need to get a key. Occasionally this key changes, so check here for the latest if there’s an issue:

gpg2 --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB

Awesome, now we can push on and grab RVM.

curl -L https://get.rvm.io | bash -s stable

Once RVM is installed we need to modify our .bashrc file which is located in the home folder. I’m using vim here:

vim ~/.bashrc

Add this to the end of the .bashrc file you are currently editing:

source $HOME/.rvm/scripts/rvm 

Exit the editor, exit your terminal.

Reopen a terminal and enter the following command – if you see password required just enter your password and hit return.

rvm requirements --autolibs=enable

RUBY

We are ready to install ruby. Head over to the official site to find the latest version of Ruby, as of this writing it is 2.7.2 so let’s install that:

rvm install 2.7.2

Instruct RVM to use 2.7.2 and set it as the default version of Ruby:

rvm use --default 2.7.2

If you type ruby -v you should see 2.7.2

RAILS

Great, let’s grab Rails. Visit the official site to find the latest version, as of this writing it is 6.0.3.4

gem install rails --version=6.0.3.4 --no-document

Whilst we are at it, if you are using MySQL, install the MySQL2 gem:

sudo apt install libmysqlclient-dev

gem install mysql2 --no-document

Type rails -v and you should see 6.0.3.4

Install Google Chrome

If you haven’t installed Chrome, let’s do that now:

wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -

sudo sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list'

sudo apt-get update

sudo apt-get install google-chrome-stable

sudo rm /etc/apt/sources.list.d/google.list*

Install Chrome Driver

Finally we will need Chrome Driver.

wget https://chromedriver.storage.googleapis.com/2.41/chromedriver_linux64.zip

unzip chromedriver_linux64.zip

sudo mv chromedriver /usr/bin/chromedriver

sudo chown root:root /usr/bin/chromedriver

sudo chmod +x /usr/bin/chromedriver

sudo rm chromedriver_linux64.zip 

That’s it, Rails is up and ready to go!

Happy Hacking 🙂

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s