Good Day my dear Linux Yogi’s,
it has been quiet some time till I posted something here and I am in for a treat. I am going to show you how to get the latest version of Ruby and Rails installed by using rbenv. There different way in installing this but in my experience this is the best working method for me.
In order to get started with this task lets ensure that your system is up to date and has all requirement installed for this to work. First off lets run the following commands to get updated.
sudo apt update sudo apt full-upgrade
Great that took care of that. Next lets get all pre-requirements installed with the following command:
sudo apt install git-core build-essential autoconf bison libreadline6-dev libssl-dev libyaml-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm3 libgdbm-dev
Awesome this is done and you can now go ahead and install rbenv with the following command:
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
This downloads it and places it in your home directory. Next you should execute the lines right below so that your Ruby on Rails environment will be available automatically.
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc echo 'eval "$(rbenv init -)"' >> ~/.bashrc
In order to make it available right away without logging out and back in, execute the line below.
The next step you will get the ruby-build plugin for rbenv. Issue the following command:
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
Now you got all the necessary pre-requirement for Ruby on Rails install with rbenv satisfied. Let’s have a look at the version available for installation. Issue the following command:
rbenv install -l
The command above will output a list of all available versions. Currently the latest stable version is 2.4.2. Lets install it with the following commands.
rbenv install 2.4.2 rbenv global 2.4.2
The first command will install Ruby 2.4.2 by using ruby-build and the second command will set and show the Ruby version. You can also execute the command below to see the installed default version.
Before we can install Rails we need to install a Ruby Gem called bundler. Run the following two commands:
echo "gem: --no-document" > ~/.gemrc gem install bundler
The first command generates a .gemrc configuration file and the second command installs the bundler gem. Now you are ready to install Rails which is a Ruby gem. Execute the following command:
gem install rails
The command above will install automatically the latest stable version of rails and in this case it is version 5.1.4. Each time you install a new version or new gem you should run the following command to make it available:
Now issue the following command and it will return the default version that is installed on your system.
cd /tmp \curl -sSL https://deb.nodesource.com/setup_6.x -o nodejs.sh
Issue the following command to add the Node.js repository to your system which makes it easier to installed the latest Node.js and also keeps it updated as well.
cat /tmp/nodejs.sh | sudo -E bash -
Awesome this is done. Let’s update our repositories and install node.js with the following two commands:
sudo apt update sudo apt install nodejs
Congratulations you installed Ruby on Rails including Node.js by using rbenv. If you like to keep your rbenv updated just execute the following two commands:
cd ~/.rbenv git pull
This keeps the rbenv updated and allows you to install newer version of Ruby and Rails.
Thank you for reading this illustration. If you like me to illustrate something you like to see please don’t hesitate to send me an email with my contact form or just leave a comment on my blog.
Until next time, Namaste my friends 😉