Using RVM on Ubuntu 12.04 to use Rails. The program 'rails' is currently not installed

11,203

Solution 1

You need to type source ~/.rvm/scripts/rvm before attempting to use Rails.

I believe the RVM installation suggests putting this line (or something similar) in your .bashrc.

Run the following command in Terminal:

echo "source \$HOME/.rvm/scripts/rvm" >> ~/.bashrc

This appends the line source \$HOME/.rvm/scripts/rvm to the end of the .bashrc file.

Doing so ensures that RVM is properly loaded each time you open up a terminal.

Solution 2

the proper fix is it https://rvm.io/integration/gnome-terminal/

you should not add source ~/.rvm/scripts/rvm to ~/.bashrc, you can find some more details here: https://rvm.io/support/faq/#shell_login

Solution 3

Here is another possibility. This happened to me. Everything was working fine and sudo'ed into root. I left the terminal open and returned a couple of days later.

rails would not work. Just like you said it was there in the gems. Turns out that I just needed to exit out of the root user and go back to my regular user and rails was fine.

Share:
11,203

Related videos on Youtube

Only Bolivian Here
Author by

Only Bolivian Here

Updated on August 02, 2022

Comments

  • Only Bolivian Here
    Only Bolivian Here almost 2 years

    I installed RVM from scratch following the installation guide on the official website. I installed Rails, created a dummy app and everything worked fine.

    I shut off my machine.

    The next morning, I turned on the machine again (cold boot) and the tried running "rails -v" from the console, but I get the following error message:

    sergio@Sergio-work ~ $ rails -v

    The program 'rails' is currently not installed. You can install it by typing: sudo apt-get install rails

    I can run ruby -v just fine, and get the following message:

    sergio@Sergio-work ~ $ ruby -v

    ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux]

    I can also run gem list just fine, output:

    sergio@Sergio-work ~ $ gem list
    
    *** LOCAL GEMS ***
    
    actionmailer (3.2.3)
    actionpack (3.2.3)
    activemodel (3.2.3)
    activerecord (3.2.3)
    activeresource (3.2.3)
    activesupport (3.2.3)
    arel (3.0.2)
    builder (3.0.0)
    bundler (1.1.4)
    coffee-rails (3.2.2)
    coffee-script (2.2.0)
    coffee-script-source (1.3.3)
    erubis (2.7.0)
    execjs (1.4.0)
    faraday (0.8.0)
    google_drive (0.3.0)
    hike (1.2.1)
    httpauth (0.1)
    i18n (0.6.0)
    journey (1.0.3)
    jquery-rails (2.0.2)
    json (1.7.3)
    libv8 (3.3.10.4 x86_64-linux)
    mail (2.4.4)
    mime-types (1.18)
    multi_json (1.3.6, 1.3.5)
    multipart-post (1.1.5)
    mysql2 (0.3.11)
    nokogiri (1.5.0)
    oauth (0.4.6)
    oauth2 (0.7.1)
    polyglot (0.3.3)
    rack (1.4.1)
    rack-cache (1.2)
    rack-ssl (1.3.2)
    rack-test (0.6.1)
    rails (3.2.3)
    railties (3.2.3)
    rake (0.9.2.2)
    rdoc (3.12)
    rubygems-bundler (1.0.2)
    rvm (1.11.3.3)
    sass (3.1.19, 3.1.18)
    sass-rails (3.2.5)
    sprockets (2.1.3)
    sqlite3 (1.3.6)
    therubyracer (0.10.1)
    thor (0.14.6)
    tilt (1.3.3)
    treetop (1.4.10)
    tzinfo (0.3.33)
    uglifier (1.2.4)
    

    Why doesn't my rails -v command work anymore? I used to have this "hack" where I would need to run a command in terminal, "source something something" once, before rails would be "recognized" as an actual command. I had to this once per terminal, meaning if I closed a terminal I had to re-run this after opening a new window terminal.

    I can't seem to find this command anymore on the Help section for RVM (where I originally found it) and since I'm kind of new to Linux, these advanced configurations are complex to me.

    Any ideas?

    • Dave Newton
      Dave Newton almost 12 years
      Did you select the appropriate ruby and gemset? Is RVM set up in your shell's startup script?
    • Todd A. Jacobs
      Todd A. Jacobs almost 12 years
      Closely related: stackoverflow.com/a/10940420/1301972. See my answer about Ubuntu's startup files.
  • tsega
    tsega over 11 years
    Thanks @mpapis, this works very well and it's the official fix.