Skip to content

Commit

Permalink
Set $LOAD_PATH instead of puppet's libdir
Browse files Browse the repository at this point in the history
Commit 7f7e74f set puppet's `libdir` to include the lib directory for
each module in the `modulepath`. Doing so enabled puppet's autoloader to
load modules that hadn't been pluginsynced. However, this only worked for
code that the autoloader directly loaded. It didn't work when the
autoloaded type, provider, etc required helper code in the same module,
or different module, because the module's lib directory was not in ruby's
$LOAD_PATH.

The commit also relied on inconsistent behavior in puppet whereby sometimes
puppet assumed `libdir` was a (semi)colon separated list of directories, and
sometimes it assumed a single directory. In Puppet 4.0, puppet will
only interpret the `libdir` setting as a single directory[1].

As a result, this commit stops setting `libdir` and instead updates the
ruby $LOAD_PATH. In doing so, rspec-puppet is the "application" the uses
puppet as a "library". In that pattern, rspec-puppet is the thing that
sets the ruby $LOAD_PATH, and puppet just uses the specified $LOAD_PATH.
This is similar to how we fixed loading faces from modules[2] in commit[3].

[1] https://tickets.puppetlabs.com/browse/PUP-3336
[2] https://projects.puppetlabs.com/issues/7316
[3] puppetlabs/puppet@4f99f25cd
  • Loading branch information
joshcooper committed Dec 3, 2014
1 parent 8459e14 commit 311ac19
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/rspec-puppet/support.rb
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,10 @@ def setup_puppet
end
end

Puppet[:libdir] = Dir["#{Puppet[:modulepath]}/*/lib"].entries.join(File::PATH_SEPARATOR)
Dir["#{Puppet[:modulepath]}/*/lib"].entries do |lib|
$LOAD_PATH << lib
end

vardir
end

Expand Down

0 comments on commit 311ac19

Please sign in to comment.