Textmate 2 Ruby Run settings for current directory

224 views Asked by At

I have Ruby 2.0.0 and TextMate 2 playing along nicely, after some TM_RUBY settings from this blog post.

However I have:

/Users/koos/Developments/RubyDevs/RubyTests/RubyLearn/Test1.rb

and

/Users/koos/Developments/RubyDevs/RubyTests/RubyLearn/Test2.rb

Test1.rb has File.open("Test2.rb")

In TM 1.5 this worked, whether I open TM at the RubyDevs levels and drill down, or if I open TM at the RubyLearn level.

In TM2 it gets "no such file or directory" if I open at RubyDevs level but is ok if I open at RubyLearn level.

It is also OK if I change to

File.open("/Users/koos/Developments/RubyDevs/RubyTests/RubyLearn/Test2.rb")

This is clearly a settings issue of some sorts.

Any advise on this?

1

There are 1 answers

1
Dirk Geurs On BEST ANSWER

First of all, this has nothing to do with Textmate but with how Ruby handles that file path. So no need to fiddle with TM settings.

You are opening a file relative to the current working directory. If you run Test1.rb from the RubyDevs directory Test2.rb is not present in the current working directory, if you open the file from the RubyLearn directory it is.

To make it work from any directory you need to determine the directory of the Test1.rb file and add the Test2.rb path like this:

file = File.open(File.dirname(__FILE__) + '/Test2.rb')
file.close()

Hope this helps!