Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I just tried rails inside a tmux session in iTerm2 and it returns as

-bash: /usr/bin/rails: /usr/bin/ruby: bad interpreter: No such file or directory

I can run rails outside of tmux . I am using Mac OSX. I've installed Ruby via RVM . Here's the output of ruby -v

ruby 1.9.3p392 (2013-02-22 revision 39386) [x86_64-darwin12.3.0]

and which ruby

/Users/user/.rvm/rubies/ruby-1.9.3-p392/bin/ruby

It's the same output for both inside tmux and normal bash shell.

Here's my ~/.tmux.conf

set -g default-terminal "screen-256color"

How am I able to run rails inside the tmux session?

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

Ensure that the bash session inside tmux is running as an interactive shell; the -i option to bash will start it in this mode. If I recall correctly, the RVM script runs from .bashrc, which is only executed for interactive shells; since it's the RVM script which adds ~/.rvm/... to your path, if it's not running, then bash will not be looking in the right place for the Ruby interpreter.

share|improve this answer
    
you mean adding -i option to tmux new -s new-tmux in the bash shell ? sorry. I am new to these stuff. –  Ye Lin Aung May 7 '13 at 15:28
    
I don't use Tmux on a regular basis, so can't give as good advice here as I like. But based on the testing I've just done, you'd need to add set-option -g default-command "/bin/bash -i" as a line in your ~/.tmux.conf to ensure that bash starts in interactive mode. –  Aaron Miller May 7 '13 at 15:44
    
It seems working now. But I see a couple of bash: preexec_invoke_exec: command not found lines and it seems annoying and bash becomes like bash-3.2$ . Here's the pic. Any ways to fix it ? –  Ye Lin Aung May 8 '13 at 0:55
    
Not off the top of my head, but this has some more information on the preexec_invoke_exec hook, which may be of help. –  Aaron Miller May 8 '13 at 15:02
add comment

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.