Fri, 28 Jul 06

TextMate and env: ruby: No such file or directory

So, I was coming up against this problem in TextMate just recently.

It’s a bit of a strange error in that you get seemingly conflicting output from TextMate.

In a new TextMate document, I could run (by using the well handy, and very new to me, Ctrl-r key combo)..

$ /usr/bin/env ruby --version
=> ruby 1.8.4 (2005-12-24) [i686-darwin8.7.1]

$ /usr/bin/which ruby
=> /usr/local/bin/ruby


puts "hello world"
=> hello world

However, if I ran..

#!/usr/bin/env ruby

puts "hello world again"
=> env: ruby: No such file or directory

Hmm, so /usr/bin/env ruby --version works, but when using the very same as the shebang interpreter we get an error. Odd huh.

Well, apparently not; if we read the textmate docs about shell commands.

Although I, in no way, understand this completely; I blindly followed the instructions on that page and got TextMate back to health.

In summary for those that don’t wish to read the docs..

$ mkdir ~/.MacOSX/
$ cat >> ~/.MacOSX/environment.plist
{ PATH = "/usr/local/bin"; }

Note You’ll want to change the path to the location of the binaries you want found.

Then a quick log out and back in, and all is well with TextMate. Yay.