0

i came across a very strange issue. i have installed rails through rvm & tested the installation. next day when i logged into system neither ruby nor rails command was found. I reinstalled everything again (rvm, ruby, rails) and tested last night. now this time i kept a terminal open and hibernated the system. but as I am trying to run rails on the new terminal instance it is giving error "bash: rails: command not found" though other commands ruby, rvm, and gem are working and its showing in rails in"gem list" however when i tried running it into the instance i kept open it works fine. what could be the issue? i have no clue really. :(

echo $PATH (terminalA - rails not working)

terminalA: /usr/lib64/qt-3.3/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:
           /usr/sbin:/sbin:/home/ankit/.rvm/bin:/home/ankit/bin:
           /home/ankit/.rvm/bin

terminalB: /home/ankit/.rvm/gems/ruby-2.0.0-p353/bin:
           /home/ankit/.rvm/gems/ruby-2.0.0-p353@global/bin:
           /home/ankit/.rvm/rubies/ruby-2.0.0-p353/bin:
           /home/ankit/.rvm/bin:/usr/lib64/qt-3.3/bin:/usr/local/bin:
           /usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/ankit/bin

EDIT: although i see that by updating the path it would work. but why is it showing 2 different values for the same system at the same time? is there anything know that cause such problem?

EDIT2: I noticed that, this command is getting removed from path everytime system wake up from hibernate. it works on terminal instance which i left open before hibernate. but on every new instance of terminal i get the command not found error.

Ankit
  • 125

1 Answers1

1

The contents of $PATH differ between the two terminals, so probably some command run in one or both of them did something(s) like:

PATH=<somedir>:$PATH

My guess is that the commands that work in A (ruby, rvm, and gem) are in an appropriate dir in your PATH in A, perhaps in:

/home/ankit/.rvm/bin

and that the rails executable (or a link to or a copy of it) may be intended to be in that dir as well, but is instead in one of:

/home/ankit/.rvm/gems/ruby-2.0.0-p353/bin
/home/ankit/.rvm/gems/ruby-2.0.0-p353@global/bin
/home/ankit/.rvm/rubies/ruby-2.0.0-p353/bin

Run the which or whereis commands for rails, ruby, rvm, and gem in both terminals, and check the file timestamps to be sure your shell is finding the recently installed versions. The executables may also support a -V or --version option.

Review the installation instructions to see if there is a 'and copy the new executable to ' or similar direction.

D McKeon
  • 765
  • last night i had set the path again, but when i started my system back the command was removed from he $PATH – Ankit Dec 19 '13 at 15:25
  • Okay, we are approaching a solution - look at both of these for more hints:
    http://unix.stackexchange.com/questions/26047/how-to-correctly-add-a-path-to-path  
    
    http://unix.stackexchange.com/questions/tagged/path
    
    – D McKeon Dec 19 '13 at 22:06
  • yes thanks, though i have quite not understood how to set the path permanently, but I've now selected option to run terminal as login shell, which loads .bash_profile automatically. – Ankit Dec 20 '13 at 06:40