Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ruby on Rails RVM $PATH issue

Used https://rvm.beginrescueend.com/rvm/install/ to install ruby (ruby 1.9.2p290) & gems (no problems), then installed rails via gem install rails (Rails 3.2.0). But when I try and create a rails app (or issue rails -v) in another directory other than my /user directory I get "The program 'rails' is currently not installed. You can install it by typing: sudo apt-get install rails" I also noticed that if I issue ruby -v I get "The program 'ruby' is currently not installed. You can install it by typing: sudo apt-get install ruby".

Obviously, this is a $PATH issue but it's been so long since I've had to do this that I've totally forgotten how to fix the issue. I'm thinking it's a simple fix but I'm feeling borderline retarded at the moment on how to solve this.

Again, as far as I can tell, as long as I create an app or issue command version commands...etc..in my /user directory all goes well.

A few things that might help as well:

which rails gives me: /home/j3/.rvm/gems/ruby-1.9.2-p290/bin/rails

which ruby gives me: /home/j3/.rvm/rubies/ruby-1.9.2-p290/bin/ruby

thanks in advance, jim

like image 267
jimmyc3po Avatar asked Jan 26 '12 13:01

jimmyc3po


2 Answers

Seems like your rvm has not been added to PATH properly (or it was broken).

Add this line to your profile settings (.bashrc or .bash_profile)

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

and source the file:

source ~/.bashrc  

or

source ~/.bash_profile

Edit: You seem to have added the echo line to .bashrc by mistake, it should be executed in terminal.

like image 184
prusswan Avatar answered Sep 20 '22 03:09

prusswan


When you try to create a new rails app in whichever directory you are in, be sure to type rvm use {ruby version} and you can also set a default by using rvm use --default {ruby version} to use that rvm version of ruby whenever you load a new terminal up.

like image 21
Simpleton Avatar answered Sep 21 '22 03:09

Simpleton