Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(PUP-11184) Return relative paths contained within the directory
Previously, puppet failed to load if the current working directory was a short Windows path. This was due to trying to require `Puppet::Util::Uniquefile` using its long and short path. This regression was introduced with the move to require_relative. The `Autoload.files_in_dir` method is expected to return relative paths that are contained within the `dir` argument. For example, returning an array containing `puppet/provider/exec/posix`. However, if the `dir` argument contained a short Windows path and the short path wasn't the last directory component, then the `files_in_dir` method returned a relative path of the form, because `Dir.glob` always returns long paths: ../../../../../../../Program Files/Puppet Labs/Puppet/puppet/lib/ruby/vendor_ruby/puppet/provider/exec/posix Later the autoloader joined `Puppet[:libdir]` and the relative path above, resulting in a non-canonical path: C:/ProgramData/PuppetLabs/puppet/cache/lib/../../../../../../../Program Files/Puppet Labs/Puppet/puppet/lib/ruby/vendor_ruby/puppet/provider/exec/posix.rb The autoloader then called `Kernel.load` with the long path: C:/Program Files/Puppet Labs/Puppet/puppet/lib/ruby/vendor_ruby/puppet/provider/exec/posix.rb Which eventually tried to require relatively uniquefile using a long path. However, that would fail because it had already been required using its 8.3 path: irb(main):002:0> $LOADED_FEATURES.grep(/\/uniquefile/) => ["C:/PROGRA~1/PUPPET~1/Puppet/puppet/lib/ruby/vendor_ruby/puppet/file_system/uniquefile.rb"] This issue wasn't an issue prior to require_relative, because we called `require 'puppet/util/uniquefile'` and ruby knew it had already required that file. This commit modifies `files_in_dir` to convert the base `dir` to a long path, so that `dir` is always a prefix for the globbed child.
- Loading branch information