deferred until inspiration hits

TextMate and "env: ruby: No such file or directory"

Posted by Chris Roos Fri, 28 Jul 2006 23:06:00

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

#!/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.

Legacy Comments

  1. Paul Battley said on Tue, 15 Aug 2006 13:02:26:

    The plist file can be either plain text or XML (maybe binary too); these instructions only work if the file is plain text or if it doesn’t exist yet. In my case, I already had an XML format file in that location.

    If it does exist, you can either edit it by hand or open it in the property list editor instead (type ‘open ~/.MacOSX/environment.plist’ in the console) and add a String key called ‘PATH’ under Root.

Trackbacks

  1. From deferred until inspiration hits on Wed, 23 Aug 2006 00:04:33

    Textmate environment and ruby (again)
    I’ve recently upgraded the version of ruby on my machine and came up against problems similar to this. The problem previously was that textmate wasn’t finding ruby at all. This time, textmate was finding the wrong version of ruby. I fo...