|
Not a regression so much as another discovered case where it has not properly worked. The fix is trivial but it breaks jar file support for load/require. This will get fully fixed after we refactor the Jar file support for 1.1.5. Bumping.
I've been exploring various cases and trying to determine the pattern in Ruby's pathing. It seems that largely, Ruby leaves relative paths relative and absolute paths absolute, using those literal paths in logging and traces. It also resolves relative paths dynamically at runtime based on the process CWD:
~/projects/jruby ➔ ruby -Ifoo -e "require 'bar'"
./foo/bar.rb:1: unhandled exception
from -e:1:in `require'
from -e:1
~/projects/jruby ➔ cd foo
~/projects/jruby/foo ➔ ruby -e "require 'bar'"
./bar.rb:1: unhandled exception
from -e:1:in `require'
from -e:1
~/projects/jruby/foo ➔ cd ../lib
~/projects/jruby/lib ➔ ruby -I../foo -e "require 'bar'"
../foo/bar.rb:1: unhandled exception
from -e:1:in `require'
from -e:1
~/projects/jruby/lib ➔ ruby -I../../jruby/foo -e "require 'bar'"
../../jruby/foo/bar.rb:1: unhandled exception
from -e:1:in `require'
from -e:1
~/projects/jruby/lib ➔ ruby -I/Users/headius/projects/jruby/foo -e "require 'bar'"
/Users/headius/projects/jruby/foo/bar.rb:1: unhandled exception
from -e:1:in `require'
from -e:1
~/projects/jruby/lib ➔ cd ..
~/projects/jruby ➔ ruby -Ifoo -e "Dir.chdir('lib'); require 'bar'"
-e:1:in `require': no such file to load -- bar (LoadError)
from -e:1
So our problem, and the reason why we always seem to have full paths in traces, is that we always turn paths into absolute paths, losing that original short path. This also represents a behavioral difference; notice in the last case that when the CWD is changed, relative paths no longer resolve the same. I'll keep poking and see if I can find a way to fix this in our LoadService. A few more interesting cases:
~/projects/jruby ➔ ruby -Ifoo -e "require 'bar'" ./foo/bar.rb:1: unhandled exception from -e:1:in `require' from -e:1 ~/projects/jruby ➔ ruby -e "require 'foo/bar'" ./foo/bar.rb:1: unhandled exception from -e:1:in `require' from -e:1 ~/projects/jruby ➔ ruby -e "require './foo/bar'" ./foo/bar.rb:1: unhandled exception from -e:1:in `require' from -e:1 Note that, while not immediately apparent here, Ruby does appear to attempt to certain paths as-is before trying load paths, and does not appear to ever attach load paths to absolute paths (which makes some sense). So adding a short-circuit that tries the path as-is first seems to also be in the cards. A couple more, showing Ruby does not attempt to search load path for a relative path based on . (CWD):
First with no bar.rb in current dir, but a bar.rb in the 'foo' dir: ~/projects/jruby ➔ ruby -Ifoo -e "require './bar.rb'" -e:1:in `require': no such file to load -- ./bar.rb (LoadError) from -e:1 Now with a bar.rb in current dir: ~/projects/jruby ➔ echo puts \'hello\' > bar.rb ~/projects/jruby ➔ ruby -Ifoo -e "require './bar.rb'" hello Obviously we need to put together specs for all the many cases. A few more that need to be specified:
Others? I am committing a set of fixes that seem to solve this and improve other cases:
So far these changes all appear to be in line with actual Ruby behavior, and the related tracing specs pass now. I'm going to optimistically commit them so they get a little burn-in time before 1.1.5. I've also posted a "wanted" email to the rubyspec list for a set of specs for all permutations of load logic and their effects on loading, _FILE_/trace, and so on, since I'm not sure I'll have time to do any myself before 1.1.5 home stretch. Committed fixes in r7854.
|
||||||||||||||||||||||||||||||||||||||||||||
So however rake invokes this is uncovering another issue. Another interesting observation is that MRI does not pass from rake either (though the output is different than ours). If I run the test like above then MRI also passes. So heh...WTF? The output is just different when run in rake and when run from command-line. I guess at a minimum we are still doing something wrong. I will at least make it fail the same way when run from rake if not make it work for both command-line and rake.