Sometimes in TextMate I get exceptions like this when trying to run unit tests:
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/pathname.rb:420:in `lstat': No such file or directory - /Users/evgeny/Projects/project/test/unit/test (Errno::ENOENT) from
<... stack trace skipped ...>
The exception above is caused by the call to realpath() in path_to_url_chunk() in Bundles/Ruby.tmbundle/Support/RubyMate/run_script.rb.
def path_to_url_chunk(path)
unless path == "untitled"
file = Pathname.new(path).realpath.to_s
"url=file://#{e_url(path)}&"
else
''
end
end
There are two problems here. First, the file variable is not used, so the hyperlink to the failed method in textmate output would be broken as a result. Second, realpath() raises an exception because for some reason (I didn’t dig deeper) the current directory is ‘/path/to/test/unit’ and path is ‘test/unit/my_test.rb’, so realpath() can’t find the test.
The modified version of the function works better:
def path_to_url_chunk(path)
unless path == "untitled"
Dir.chdir "../.."
file = Pathname.new(path).realpath.to_s
"url=file://#{e_url(file)}&"
else
''
end
end
It’s not a proper solution because the either the file path or the working directory should be corrected before this function is called. If you know a better solution to this problem, please leave a comment.