Ruby installation on linux

How To Install Ruby on Ubuntu & Debian

Ruby is a popular programming language among a large number of developers. Rails are the framework to run the ruby language. Ruby language was created by Yukihiro “Matz” Matsumoto and first published in 1995. This article will help you to install ruby on rails on Ubuntu and LinuxMint Linux systems using RVM. RVM is the Ruby Version Manager that helps for installing and managing Ruby language on systems.

In this blog post, you will get instructions to install Ruby on a Ubuntu and Debian system.

Step 1 – Installing RVM

First of all, install the latest stable version of RVM on your system using the following command. This command will automatically download all required files and install them on your system.

    Make sure that the curl command line utility is installed on your system

sudo apt install curl gnupg2 
curl -sSL https://rvm.io/mpapis.asc | sudo gpg2 --import - curl -sSL https://rvm.io/pkuczynski.asc | sudo gpg2 --import - 
curl -sSL https://get.rvm.io | sudo bash -s stable 

Step 2 – List Available Ruby Versions

Get a list of available versions of Ruby language. You can install any version of your choice or requirements shown on the list.

Output
# MRI Rubies [ruby-]1.8.6[-p420] [ruby-]1.8.7[-head] # security released on head [ruby-]1.9.1[-p431] [ruby-]1.9.2[-p330] [ruby-]1.9.3[-p551] [ruby-]2.0.0[-p648] [ruby-]2.1[.10] [ruby-]2.2[.10] [ruby-]2.3[.8] [ruby-]2.4[.10] [ruby-]2.5[.8] [ruby-]2.6[.6] [ruby-]2.7[.2] [ruby-]3[.0.0] ruby-head

Step 3 – Installing Ruby on Ubuntu & Debian

RVM is useful for the installation of multiple Ruby versions on a single system. Use the following command to install the required Ruby on your system.

Читайте также:  Linux mint камера ноутбука

Use one of the below commands to install a specific version of Ruby on your system.

Step 4 – Set the Default Ruby Version

Use the rvm command to set up the default ruby version to be used by applications. You can install multiple versions as defined in the above step. Now select which version you want to use.

rvm use 3.0 --default Using /usr/local/rvm/gems/ruby-3.0.0

Step 5 – Check Ruby Version

Using the following command you can check the current ruby version is used.

ruby --version ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-linux]

Step 6 – Install Rails

You can install the latest stable release version of Rails by running the following command. It will install Rails in global Gemset So that all applications share the same version of Rails.

Or we can get a specific version of Rails by defining –version during installation. Visit here to get available rails versions.

gem install rails --version=7.0.3 

Conclusion

Congratulation’s, You have successfully installed Ruby on your system. Read our next articles to deploy Ruby with Apache or Ruby with Nginx web server with simple steps.

How to Install Ruby on Ubuntu 20.04

How to Install Ruby on CentOS/RHEL 8 and Scientific Linux

How to Install Ruby on Debian with RVM

22 Comments

in step if u have gpg2 package missing then do sudo apt-get install gnupg2 in step 4 rvm will not set ruby version to default directly if throw error ” RVM is not a function, selecting rubies with ‘rvm use …’ will not work.” then do :
bash –login
rvm –default use 2.6.6

Читайте также:  Linux list all drives

I think you need to use sudo in this case since the /usr directory is protected under super user access only. Try
>> sudo rvm requirements

$ rvm requirements
Checking requirements for mint.
Installing requirements for mint.
mkdir: cannot create directory ‘/usr/local/rvm/log/1527792630’: Permission denied
tee: /usr/local/rvm/log/1527792630/update_system.log: No such file or directory
Updating system…..
Error running ‘requirements_debian_update_system ‘,
please read /usr/local/rvm/log/1527792630/update_system.log
Requirements installation failed with status: 1.

Hi I keep getting this error /usr/local/rvm/gems/ruby-2.4.1/gems/bundler-1.16.1/lib/bundler/runtime.rb:84:in `rescue in block (2 levels) in require’: There was an error while trying to load the gem ‘uglifier’. (Bundler::GemRequireError)
Gem Load Error is: Could not find a JavaScript runtime. See https://github.com/rails/execjs for a list of available runtimes.

[email protected] ~/Documents/Rails/TestApps/GamesRailsProject/SampleApp $ source /etc/profile.d/rvm.sh
[email protected] ~/Documents/Rails/TestApps/GamesRailsProject/SampleApp $ rails server
/usr/local/rvm/gems/ruby-2.4.1/gems/bundler-1.16.1/lib/bundler/runtime.rb:84:in `rescue in block (2 levels) in require’: There was an error while trying to load the gem ‘uglifier’. (Bundler::GemRequireError)
Gem Load Error is: Could not find a JavaScript runtime. See https://github.com/rails/execjs for a list of available runtimes.
Backtrace for gem load error is:
/usr/local/rvm/gems/ruby-2.4.1/gems/execjs-2.7.0/lib/execjs/runtimes.rb:58:in `autodetect’
/usr/local/rvm/gems/ruby-2.4.1/gems/execjs-2.7.0/lib/execjs.rb:5:in `’
/usr/local/rvm/gems/ruby-2.4.1/gems/execjs-2.7.0/lib/execjs.rb:4:in `’
/usr/local/rvm/gems/ruby-2.4.1/gems/uglifier-3.2.0/lib/uglifier.rb:5:in `require’
/usr/local/rvm/gems/ruby-2.4.1/gems/uglifier-3.2.0/lib/uglifier.rb:5:in `’
/usr/local/rvm/gems/ruby-2.4.1/gems/bundler-1.16.1/lib/bundler/runtime.rb:81:in `require’
/usr/local/rvm/gems/ruby-2.4.1/gems/bundler-1.16.1/lib/bundler/runtime.rb:81:in `block (2 levels) in require’
/usr/local/rvm/gems/ruby-2.4.1/gems/bundler-1.16.1/lib/bundler/runtime.rb:76:in `each’
/usr/local/rvm/gems/ruby-2.4.1/gems/bundler-1.16.1/lib/bundler/runtime.rb:76:in `block in require’
/usr/local/rvm/gems/ruby-2.4.1/gems/bundler-1.16.1/lib/bundler/runtime.rb:65:in `each’
/usr/local/rvm/gems/ruby-2.4.1/gems/bundler-1.16.1/lib/bundler/runtime.rb:65:in `require’
/usr/local/rvm/gems/ruby-2.4.1/gems/bundler-1.16.1/lib/bundler.rb:114:in `require’
/home/dave/Documents/Rails/TestApps/GamesRailsProject/SampleApp/config/application.rb:7:in `’
/usr/local/rvm/gems/ruby-2.4.1/gems/railties-5.1.2/lib/rails/commands/server/server_command.rb:129:in `require’
/usr/local/rvm/gems/ruby-2.4.1/gems/railties-5.1.2/lib/rails/commands/server/server_command.rb:129:in `block in perform’
/usr/local/rvm/gems/ruby-2.4.1/gems/railties-5.1.2/lib/rails/commands/server/server_command.rb:126:in `tap’
/usr/local/rvm/gems/ruby-2.4.1/gems/railties-5.1.2/lib/rails/commands/server/server_command.rb:126:in `perform’
/usr/local/rvm/gems/ruby-2.4.1/gems/thor-0.20.0/lib/thor/command.rb:27:in `run’
/usr/local/rvm/gems/ruby-2.4.1/gems/thor-0.20.0/lib/thor/invocation.rb:126:in `invoke_command’
/usr/local/rvm/gems/ruby-2.4.1/gems/thor-0.20.0/lib/thor.rb:387:in `dispatch’
/usr/local/rvm/gems/ruby-2.4.1/gems/railties-5.1.2/lib/rails/command/base.rb:63:in `perform’
/usr/local/rvm/gems/ruby-2.4.1/gems/railties-5.1.2/lib/rails/command.rb:44:in `invoke’
/usr/local/rvm/gems/ruby-2.4.1/gems/railties-5.1.2/lib/rails/commands.rb:16:in `’
/home/dave/Documents/Rails/TestApps/GamesRailsProject/SampleApp/bin/rails:9:in `require’
/home/dave/Documents/Rails/TestApps/GamesRailsProject/SampleApp/bin/rails:9:in `’
/usr/local/rvm/gems/ruby-2.4.1/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `load’
/usr/local/rvm/gems/ruby-2.4.1/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `call’
/usr/local/rvm/gems/ruby-2.4.1/gems/spring-2.0.2/lib/spring/client/command.rb:7:in `call’
/usr/local/rvm/gems/ruby-2.4.1/gems/spring-2.0.2/lib/spring/client.rb:30:in `run’
/usr/local/rvm/gems/ruby-2.4.1/gems/spring-2.0.2/bin/spring:49:in `’
/usr/local/rvm/gems/ruby-2.4.1/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `load’
/usr/local/rvm/gems/ruby-2.4.1/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `’
/home/dave/Documents/Rails/TestApps/GamesRailsProject/SampleApp/bin/spring:15:in `require’
/home/dave/Documents/Rails/TestApps/GamesRailsProject/SampleApp/bin/spring:15:in `’
bin/rails:3:in `load’
bin/rails:3:in `’
Bundler Error Backtrace:
from /usr/local/rvm/gems/ruby-2.4.1/gems/bundler-1.16.1/lib/bundler/runtime.rb:80:in `block (2 levels) in require’
from /usr/local/rvm/gems/ruby-2.4.1/gems/bundler-1.16.1/lib/bundler/runtime.rb:76:in `each’
from /usr/local/rvm/gems/ruby-2.4.1/gems/bundler-1.16.1/lib/bundler/runtime.rb:76:in `block in require’
from /usr/local/rvm/gems/ruby-2.4.1/gems/bundler-1.16.1/lib/bundler/runtime.rb:65:in `each’
from /usr/local/rvm/gems/ruby-2.4.1/gems/bundler-1.16.1/lib/bundler/runtime.rb:65:in `require’
from /usr/local/rvm/gems/ruby-2.4.1/gems/bundler-1.16.1/lib/bundler.rb:114:in `require’
from /home/dave/Documents/Rails/TestApps/GamesRailsProject/SampleApp/config/application.rb:7:in `’
from /usr/local/rvm/gems/ruby-2.4.1/gems/railties-5.1.2/lib/rails/commands/server/server_command.rb:129:in `require’
from /usr/local/rvm/gems/ruby-2.4.1/gems/railties-5.1.2/lib/rails/commands/server/server_command.rb:129:in `block in perform’
from /usr/local/rvm/gems/ruby-2.4.1/gems/railties-5.1.2/lib/rails/commands/server/server_command.rb:126:in `tap’
from /usr/local/rvm/gems/ruby-2.4.1/gems/railties-5.1.2/lib/rails/commands/server/server_command.rb:126:in `perform’
from /usr/local/rvm/gems/ruby-2.4.1/gems/thor-0.20.0/lib/thor/command.rb:27:in `run’
from /usr/local/rvm/gems/ruby-2.4.1/gems/thor-0.20.0/lib/thor/invocation.rb:126:in `invoke_command’
from /usr/local/rvm/gems/ruby-2.4.1/gems/thor-0.20.0/lib/thor.rb:387:in `dispatch’
from /usr/local/rvm/gems/ruby-2.4.1/gems/railties-5.1.2/lib/rails/command/base.rb:63:in `perform’
from /usr/local/rvm/gems/ruby-2.4.1/gems/railties-5.1.2/lib/rails/command.rb:44:in `invoke’
from /usr/local/rvm/gems/ruby-2.4.1/gems/railties-5.1.2/lib/rails/commands.rb:16:in `’
from /home/dave/Documents/Rails/TestApps/GamesRailsProject/SampleApp/bin/rails:9:in `require’
from /home/dave/Documents/Rails/TestApps/GamesRailsProject/SampleApp/bin/rails:9:in `’
from /usr/local/rvm/gems/ruby-2.4.1/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `load’
from /usr/local/rvm/gems/ruby-2.4.1/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `call’
from /usr/local/rvm/gems/ruby-2.4.1/gems/spring-2.0.2/lib/spring/client/command.rb:7:in `call’
from /usr/local/rvm/gems/ruby-2.4.1/gems/spring-2.0.2/lib/spring/client.rb:30:in `run’
from /usr/local/rvm/gems/ruby-2.4.1/gems/spring-2.0.2/bin/spring:49:in `’
from /usr/local/rvm/gems/ruby-2.4.1/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `load’
from /usr/local/rvm/gems/ruby-2.4.1/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `’
from /home/dave/Documents/Rails/TestApps/GamesRailsProject/SampleApp/bin/spring:15:in `require’
from /home/dave/Documents/Rails/TestApps/GamesRailsProject/SampleApp/bin/spring:15:in `’
from bin/rails:3:in `load’
from bin/rails:3:in `’

Читайте также:  Windows 10 linux ssd диск

Thanks for the tutorial.
It didn’t work with Linux Mint. I think rvm does not recognize Mint as an Ubuntu derivative. It does not find binaries for Mint and the compile fails. I tried various different version numbers and the compilation errors are slightly different but generally some files are not found e.g. ‘strlcat.c’

Источник

Оцените статью
Adblock
detector