Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: None
-
Fix Version/s: JRuby 1.x+
-
Component/s: Core Classes/Modules
-
Labels:None
-
Number of attachments :
Description
There are many different combinations of logic involved in the loading of files. Very few of them have a clear set (or perhaps any set) of codified specifications. This bug can be a placeholder for recording various combinations of behavior, in the hope that a set of specifications will follow (and fixes to JRuby will follow that).
I'll start it off with a failing case in JRuby with load of a file using ./ pathing:
~/projects/jruby ➔ jruby -Ifoo -e "load 'foo/bar.rb'" foo/bar.rb:1: unhandled exception from foo/bar.rb:1:in `load' from -e:1 ~/projects/jruby ➔ ruby -Ifoo -e "load 'foo/bar.rb'" ./foo/bar.rb:1: unhandled exception from -e:1:in `load' from -e:1
From
JRUBY-2909: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:1So 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.
JRUBY-2909: 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