From 311ac19d9925767f375df2d0ee411c38ca4f9483 Mon Sep 17 00:00:00 2001 From: Josh Cooper Date: Tue, 2 Dec 2014 21:32:32 -0800 Subject: [PATCH] Set $LOAD_PATH instead of puppet's libdir Commit 7f7e74f02c 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] https://github.com/puppetlabs/puppet/commit/4f99f25cd --- lib/rspec-puppet/support.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/rspec-puppet/support.rb b/lib/rspec-puppet/support.rb index bddf87140..6b38cf40f 100644 --- a/lib/rspec-puppet/support.rb +++ b/lib/rspec-puppet/support.rb @@ -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