3

I followed this tutorial to install ruby with rvm: https://www.digitalocean.com/community/tutorials/how-to-install-ruby-on-rails-on-ubuntu-12-04-lts-precise-pangolin-with-rvm

The problem is that everytime that I log in, the ruby installation is not recognized, for example if I try executing a ruby script with the "ruby" command this is what I get:

enter image description here

To make it be recognized I have to run this command:

source ~/.rvm/scripts/rvm

But every time I login I have to do it again.

2

You can install Ruby by typing:

sudo apt-get install ruby-full

See the Doc.

5

What went wrong?

During installation, rvm puts two lines (first one is a comment though) in ~/.bash_profile file to help bash recognize ruby binaries. But the problem is Ubuntu's bash ignores this file. As a result, it doesn't know that you already installed ruby and prompts you to install ruby!

The problem can be solved in two different way.


Solution 1: Using ~/.bashrc file

Open your ~/.bashrc file and put these two lines (or last one) there.

### Load RVM into a shell session *as a function*
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"

Solution 2: Make the regular shell session as login shell

Or you can turn on your virtual terminal's preference to consider the shell as Login Shell. The settings can be found in -

  • Gnome Terminal: Menu > Edit > Profile Preference > Command Tab > Run command as a login shell

  • Mate Terminal: Menu > Edit > Profile Preference > Title & Command Tab > Run command as a login shell

  • Xfce4 Terminal: Menu > Edit > Preference > General Tab > Run command as login shell

Either one will do the job.


Another solution could be installing Ruby in System using Ubuntu's repository. But that defeats the purpose of using rvm at first place.

  • This is the answer to the question asked. Why is it not the accepted answer? – Tony Cronin Dec 27 '16 at 13:13
  • 1
    @TonyCronin This is added after 2 years, The OP might not active now. I appreciate your support though. Thanks ! – Anwar Dec 27 '16 at 13:29
0

This will install old version of ruby (1.9) currently existing in Ubuntu repos. You might want to check installation from source

Download ruby tar from here and then run:

$ tar -xf ruby-your-downloaded-package
$ cd ruby_extracted_directory
$ ./configure
$ make
$ sudo make install

In some cases you will need to realod bash by typing:

$ bash

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.