[SVN] Re: Patch for RubyMate: 'No such file or directory' when filename cannot be resolved

Stonefield knut.stenmark at gmail.com
Tue Jun 2 19:23:37 UTC 2009


This problem emerged again with Rails 2.3.x. I hope I have fixed it this
time.
The actual problem occur if running e.g. a test script with cmd-r.
Executor looks for the referenced file from current directory, which may be
where the file being run is located, where as the output from the script is
referring to the project directory.
The actual_path_name function solves this, where 2 attempts are done. FIrst
checks to see if the file referenced is relative to the current directory,
if that fails, prefixes the referenced file with the project directory. This
is really a better patch than the previous one, but not as pretty.

diff --git a/Bundles/Ruby.tmbundle/Support/RubyMate/run_script.rb
b/Bundles/Ruby.tmbundle/Support/RubyMate/run_script.rb
index 75f1cca..60cf80d 100755
--- a/Bundles/Ruby.tmbundle/Support/RubyMate/run_script.rb
+++ b/Bundles/Ruby.tmbundle/Support/RubyMate/run_script.rb
@@ -66,6 +66,22 @@ def path_to_url_chunk(path)
  end
end

+def actual_path_name(path)
+  prefix = ''
+  2.times do
+    begin
+      file = Pathname.new(prefix + path).realpath.to_s
+      url = '&url=file://' + e_url(file)
+      display_name = File.basename(file)
+      return file, url, display_name
+    rescue Errno::ENOENT
+      # Hmm lets try to prefix with project directory
+      prefix = "#{ENV['TM_PROJECT_DIRECTORY']}/"
+    end
+  end
+  return path, '', path
+end
+
TextMate::Executor.run( cmd, :version_args => ["--version"],
                             :script_args  => args ) do |line, type|
  if is_test_script and type == :out
@@ -82,13 +98,7 @@ TextMate::Executor.run( cmd, :version_args =>
["--version"],
          if file == '(eval)'
            display_name = file
          else
-            begin
-              file = Pathname.new(file).realpath.to_s
-              url = '&url=file://' + e_url(file)
-              display_name = File.basename(file)
-            rescue Errno::ENOENT
-              display_name = file
-            end
+            file, url, display_name = actual_path_name(file)
          end
        end
        out = indent


On Thu, Feb 5, 2009 at 6:36 PM, James Gray <james at grayproductions.net>wrote:

> On Feb 5, 2009, at 2:51 AM, Stonefield wrote:
>
> > Sometimes the ouput from a run test command does not contain a
> > resolvable file name, which leads to the output raises an exception.
> > The enclosed patch fixes this problem (git diff).
>
> Looks good to me.  Applied.
>
> James Edward Gray II
> _______________________________________________
> textmate-dev mailing list
> textmate-dev at lists.macromates.com
> http://lists.macromates.com/listinfo/textmate-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macromates.com/textmate-dev/attachments/20090602/0a55a0c6/attachment.html>


More information about the textmate-dev mailing list