Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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.

share|improve this question
    
What's the output of whereis ruby and echo $PATH ? –  schaiba Dec 18 '13 at 20:17
    
@schaiba edited question –  ay89 Dec 18 '13 at 20:21
    
@ay89 I added some formatting to the echo $PATH output to make it more readable. Feel free to rollback if you feel the edit is unnecessary. –  Joseph R. Dec 18 '13 at 20:35
    
yes thanks its more readable now. @JosephR. –  ay89 Dec 18 '13 at 20:36

1 Answer 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.

share|improve this answer
    
last night i had set the path again, but when i started my system back the command was removed from he $PATH –  ay89 Dec 19 '13 at 15:25
    
Okay, we are approaching a solution - look at both of these for more hints: unix.stackexchange.com/questions/26047/… 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. –  ay89 Dec 20 '13 at 6:40

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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