Facebook Twitter Instagram
    TecAdmin
    • Home
    • Ubuntu 20.04
      • Upgrade Ubuntu
      • Install Java
      • Install Node.js
      • Install Docker
      • Install LAMP Stack
    • Tutorials
      • AWS
      • Shell Scripting
      • Docker
      • Git
      • MongoDB
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    Home»Programming»Ruby»How To Install Ruby on Ubuntu using RVM

    How To Install Ruby on Ubuntu using RVM

    RahulBy RahulAugust 25, 20154 Mins ReadUpdated:June 10, 2022

    Ruby is a popular programming language among a large number of developers. Rails are the framework to run 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 helps for installing and managing Ruby language on systems.

    Step 1 – Install 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 on your system.

    Install CURL

    apt-get install curl
    

    Install RVM

    Before installing RVM first we need to import public key in our system then use curl to install rvm in our system.

    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
    

    After installing RVM first we need to set up rvm environment using below command. so that current shell takes new environment settings.

    source /etc/profile.d/rvm.sh
    

    Install Ruby Dependencies

    Install all the dependencies for installing Ruby automatically on the system. Run below command on terminal.

    rvm requirements
    

    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 showing on the list.

    rvm list known
    
    [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[.6]
    [ruby-]2.5[.5]
    [ruby-]2.6[.3]
    [ruby-]2.7[.0-preview1]
    ruby-head
    

    Step 3 – Install Ruby on Ubuntu

    RVM is useful for installation of multiple Ruby versions on the single system. Use the following command to install required Ruby on your system. As shown below example will install Ruby 2.4.1 on your system.

    rvm install 2.6
    

    [Sample Output]

    Searching for binary rubies, this might take some time.
    No binary rubies available for: ubuntu/18.04/x86_64/ruby-2.6.3.
    Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.
    Checking requirements for ubuntu.
    Requirements installation successful.
    Installing Ruby from source to: /usr/local/rvm/rubies/ruby-2.6.3, this may take a while depending on your cpu(s)...
    ruby-2.6.3 - #downloading ruby-2.6.3, this may take a while depending on your connection...
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100 13.8M  100 13.8M    0     0  13.8M      0 --:--:-- --:--:-- --:--:-- 13.8M
    ruby-2.6.3 - #extracting ruby-2.6.3 to /usr/local/rvm/src/ruby-2.6.3.....
    ruby-2.6.3 - #configuring......................................................................
    ruby-2.6.3 - #post-configuration..
    ruby-2.6.3 - #compiling...........................................................................................
    ruby-2.6.3 - #installing................
    ruby-2.6.3 - #making binaries executable..
    ruby-2.6.3 - #downloading rubygems-3.0.4
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100  862k  100  862k    0     0  24.0M      0 --:--:-- --:--:-- --:--:-- 24.0M
    ruby-2.6.3 - #extracting rubygems-3.0.4.....
    ruby-2.6.3 - #removing old rubygems........
    ruby-2.6.3 - #installing rubygems-3.0.4.........................................
    ruby-2.6.3 - #gemset created /usr/local/rvm/gems/[email protected]
    ruby-2.6.3 - #importing gemset /usr/local/rvm/gemsets/global.gems................................................................
    ruby-2.6.3 - #generating global wrappers.......
    ruby-2.6.3 - #gemset created /usr/local/rvm/gems/ruby-2.6.3
    ruby-2.6.3 - #importing gemsetfile /usr/local/rvm/gemsets/default.gems evaluated to empty gem list
    ruby-2.6.3 - #generating default wrappers.......
    ruby-2.6.3 - #adjusting #shebangs for (gem irb erb ri rdoc testrb rake).
    Install of ruby-2.6.3 - #complete
    

    Step 4 – Setup Default Ruby Version

    Use rvm command to set up 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 2.6.3 --default 
    
    Using /usr/local/rvm/gems/ruby-2.6.3
    

    Step 5 – Check Ruby Version

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

    ruby --version
    
    ruby 2.6.3p62 (2019-04-16 revision 67580) [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.

    gem install rails
    rails -v
    

    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=5.2.3
    

    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.

    rails ROR ruby Ruby on Rails rvm
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp
    Previous ArticleHow to Delete Git Remote and Local Branch
    Next Article How to Install NetBeans IDE 8.2 (PHP) on Ubuntu Desktop

    Related Posts

    How to Install Ruby on Ubuntu 20.04

    Updated:July 27, 20204 Mins Read

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

    Updated:April 3, 20203 Mins Read

    How to Install Ruby on Debian with RVM

    Updated:November 10, 20204 Mins Read

    How to Deploy Ruby App with Nginx and Passenger on Ubuntu and Debian

    Updated:November 1, 20173 Mins Read

    How to Deploy Ruby App with Apache and Passenger on Ubuntu and Debian

    Updated:October 31, 20173 Mins Read

    How to Deploy Ruby Application with Passenger and Apache on CentOS 7/6, Fedora 27

    Updated:October 31, 20172 Mins Read

    22 Comments

    1. tyson on March 7, 2021 4:14 pm

      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

      Reply
    2. Aether on January 13, 2021 1:29 pm

      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

      Reply
    3. Isabelle on February 7, 2019 4:35 pm

      Thanks!

      Reply
    4. Nirmal Sinha on June 19, 2018 6:58 am

      Thanks, Bro

      Reply
    5. Mark Long on May 31, 2018 6:52 pm

      $ 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.

      Reply
    6. David Merrick on March 28, 2018 8:45 pm

      Problem solved needed to install Node.js using sudo apt-get install nodejs

      Reply
    7. David Merrick on March 28, 2018 5:37 am

      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.

      Reply
    8. David Merrick on March 28, 2018 4:39 am

      [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 `’

      Reply
    9. JMQ on September 10, 2017 3:42 pm

      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’

      Reply
    10. f4b1 on April 14, 2017 8:21 am

      It’s Work, thanks for this tips !

      Reply
    11. Taufan Fatahillah Haigal Maulana on August 22, 2016 2:14 pm

      How to fix bash: /etc/profile.d/rvm.sh: No such file or directory

      Reply
      • Sasa on October 24, 2016 7:34 pm

        Just open new terminal window to start anew. I too did not find the file but it was not needed.

        Reply
    12. Anonymous on July 19, 2016 2:44 am

      Good tutorial!

      Reply
    13. lexprimost on May 20, 2016 9:39 am

      everything works fine sometime you just need to type “sudo” before camands to get root permissions
      thank you Rahul

      Reply
    14. Tom on March 6, 2016 6:21 pm

      Not a good tutorial. Nothing was saved even when I ran the commands as root.

      Reply
    15. Mark on January 29, 2016 4:57 pm

      In my instance I had to enable the “Run command as a login shell” option for my terminal in Mint.

      Edit > Profile Preferences > Title and Command > Run Command as login shell

      Everything worked perfectly after that.

      Reply
      • Sasa on October 24, 2016 7:37 pm

        You do not need to do that. Instead use command
        $> rvm alias create default X.Y.Z
        when setting the default ruby. (change X,Y,Z for the correct numbers)

        If not sure about the numbers/versions, use
        $> rvm list
        to see what versions you have installed

        Reply
    16. dX on May 11, 2015 10:31 pm

      This works, but when i turn off the terminal its all gone? Why, i was using terminal in root mode.

      Reply
      • Joe on January 5, 2016 7:07 am

        same thing happened to me

        Reply
        • Rahul on January 5, 2016 9:34 am

          Hi Joe,

          Can you please explain your issue more ?

          Reply
          • Joe on January 5, 2016 8:07 pm

            Hi Rahul
            I installed the program as root but when I log on as a normal user it’s not available.
            Would I need to reinstall as normal user or is there another way?
            Many thanks

            Reply
      • Dejan on March 3, 2017 12:10 pm

        you must type:

        # source /etc/profile.d/rvm.sh

        every time before working with it. I’v added this line to .bashrc file in my home directory on linux mint. Now it is fine and no need to type it every time.

        Reply

    Leave A Reply Cancel Reply

    Recent Posts
    • How To Install Docker on Ubuntu 22.04
    • How to Install Bower on Ubuntu 22.04 & 20.04
    • How to run “npm start” through Docker
    • Filesystem Hierarchy Structure (FHS) in Linux
    • How to accept user input in Python
    Facebook Twitter Instagram Pinterest
    © 2022 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.