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.
This worked for me… Thank you very much. Very nice to not have this popup form time to time and then be forced to work from the command line
We’ve struggled with the same thing, although the fix above broke for some other spurious reason. Here’s the implementation we ended up with:
def path_to_url_chunk(path)
unless path == “untitled”
prefix = ”
2.times do
begin
file = Pathname.new(prefix + path).realpath.to_s
“url=file://#{e_url(file)}&”
rescue Errno::ENOENT
# Hmm lets try to prefix with project directory
prefix = “#{ENV['TM_PROJECT_DIRECTORY']}/”
end
end
else
”
end
end
Thanks so much, been putting up with this when running failing tests for a while, finally today I felt like I had to do something about it.
In case anyone is having trouble with the old
`require’: no such file to load — test_helper (LoadError)
when running tests on the command line should set this environment variable
RUBYLIB=”.:test:$RUBYLIB”
Stephen,
Can you elaborate on your solution for that annoying test_helper message?
Thanks!
Tom
I ran into the same problem. It occurred in my Rails unit test when I added an assert_raise clause. Turns out there’s already a patch for it in Ruby bundle for TextMate:
http://www.nabble.com/Patch-for-RubyMate:-‘No-such-file-or-directory’-when-backtrace-contains-eval-td21506903.html
So I installed the latest bundle off of trunk and problem solved. Did this work for you?
Sorry, didn’t try it yet. I googled a bit before writing this post but couldn’t find that patch.