2

I have installed ruby on rails following the 310 railcasts on railcast.com. Now I was able to run and create a new rails and run it using rail s. The issue comes as soon has I close the terminal and restarted it i get the following error

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

Here ruby version

ruby -v
ruby 1.9.3p286 (2012-10-12 revision 37165) [i686-linux]

if i do rails -v i get following

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

whereis rails
rails:

gem environment gives me this

  - RUBYGEMS VERSION: 1.8.24
  - RUBY VERSION: 1.9.3 (2012-10-12 patchlevel 286) [i686-linux]
  - INSTALLATION DIRECTORY: /home/john/.rvm/gems/ruby-1.9.3-p286
  - RUBY EXECUTABLE: /home/john/.rvm/rubies/ruby-1.9.3-p286/bin/ruby
  - EXECUTABLE DIRECTORY: /home/john/.rvm/gems/ruby-1.9.3-p286/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86-linux
  - GEM PATHS:
     - /home/john/.rvm/gems/ruby-1.9.3-p286
     - /home/john/.rvm/gems/ruby-1.9.3-p286@global
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :benchmark => false
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - http://rubygems.org/

I also believe the answer his the path and seem to the same has this questions Installed Rails but the rails command says it's not installed. But i do not know how to place the path. Any help would be appreciated

Community
  • 1
  • 1
Jseb
  • 1,786
  • 4
  • 21
  • 43

5 Answers5

2

try to type rvm -v, if an error occurs, you have a problem with your rvm installation, if so try to source your shell configuration file ie if you are using bash on a mac : "source ~/.profile"

overlox
  • 654
  • 1
  • 5
  • 17
  • I just try rvm -v and here the output: rvm 1.16.13 (stable) by Wayne E. Seguin , Michal Papis [https://rvm.io/] – Jseb Oct 15 '12 at 03:55
1

I am using Mac OSX, and in my .bashrc which is under my home directory. There is a line : PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting

By the way, you should tell the rvm to use 1.9.3 of ruby by the command rvm use 1.9.3

code4j
  • 3,498
  • 3
  • 30
  • 49
1

Your problem could be the thing that rvm switches between your ruby versions and when you restart the terminal it is not the old ruby version that you were using before exiting. So one solution can be. You create ".rvmrc" file in your rails application folder and inside you put just one line:

rvm use 1.x.x

where 1.x.x is the ruby version that you will use. Once you have gem rails in this version it will always work for you. This file simply tells which ruby shell be used when you work in your aplication direcotry

Dragan
  • 480
  • 3
  • 11
1

@user1022209 your solution will also work if the problem is with the ruby version but the point is that you always have to set ruby when your enter your folder and this can somethimes be anoying. I think that the best way to set default ruby version is using .rvmrc file.

3 lines of writing:

vim .rvmrc #creates new file, after which you have to press "i" for Insert mode

rvm use 1.x.x #contains only this line inside after which you press "ESC" and you type

:wq or :wq!

Finally press Enter and you are done forever :)

Hope it will solve your problem

Dragan
  • 480
  • 3
  • 11
0

gem install rails

Do not sudo or apt-get when installing Rails with an installation of Ruby that was compiled from source. You may need to remove the Rails package first since you have already attempted to install it using the apt-get package manager.

apt-get remove --purge rails

apt-get clean

scarver2
  • 7,589
  • 2
  • 50
  • 58