2: from a.rb:3:in `<main>' |
1: from a.rb:3:in `load' |
C:/abcdefghijk/c.rb:3:in `<top (required)>': superclass mismatch for class C (TypeError)
|
This fails because c.rb is loaded first using its shortname, then an attempt is made it load it again using its long name. Puppet runs into this, because the autoloader uses Dir.glob to find candidate files to load, and ruby always returns globbed children using long paths:
dir = Pathname.new(File.expand_path(dir)) |
Dir.glob(File.join(dir, path, "*.rb")).collect do |file| |
Pathname.new(file).relative_path_from(dir).to_s |
end
|
Interestingly, Pathname#relative_path_from gets confused with file is a long path and dir is a short path:
../../../../../../../Program Files/Puppet Labs/Puppet/puppet/lib/ruby/vendor_ruby/puppet/provider/exec/posix
|
It's possible to normalize that using File.expand_path:
irb(main):001:0> File.expand_path("../../../../../../../Program Files/Puppet Labs/Puppet/puppet/lib/ruby/vendor_ruby/puppet/provider/exec/posix") |
=> "C:/Program Files/Puppet Labs/Puppet/puppet/lib/ruby/vendor_ruby/puppet/provider/exec/posix"
|
But I think the least surprising thing would be to resolve the long path name for the base dir so that the globbed children have the same prefix. Some of this was done in PUP-6557, but the autoloader wasn't touched. It didn't need to be because we weren't using require_relative yet. |