1

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?

Ye Lin Aung
  • 5,650
  • 7
  • 32
  • 35

1 Answers1

2

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.

Aaron Miller
  • 9,782
  • 24
  • 39
  • 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 07 '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 07 '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](http://i.imgur.com/Hf73xgC.png). Any ways to fix it ? – Ye Lin Aung May 08 '13 at 00:55
  • Not off the top of my head, but [this](http://superuser.com/questions/175799/does-bash-have-a-hook-that-is-run-before-executing-a-command) has some more information on the `preexec_invoke_exec` hook, which may be of help. – Aaron Miller May 08 '13 at 15:02