{"action":"created","issue":{"url":"https://api.github.com/repos/rodjek/rspec-puppet/issues/264","labels_url":"https://api.github.com/repos/rodjek/rspec-puppet/issues/264/labels{/name}","comments_url":"https://api.github.com/repos/rodjek/rspec-puppet/issues/264/comments","events_url":"https://api.github.com/repos/rodjek/rspec-puppet/issues/264/events","html_url":"https://github.com/rodjek/rspec-puppet/issues/264","id":65526927,"number":264,"title":"Colon-separated Puppet[:libdir] breaks fixtures' `require`","user":{"login":"hunner","id":91972,"avatar_url":"https://avatars.githubusercontent.com/u/91972?v=3","gravatar_id":"","url":"https://api.github.com/users/hunner","html_url":"https://github.com/hunner","followers_url":"https://api.github.com/users/hunner/followers","following_url":"https://api.github.com/users/hunner/following{/other_user}","gists_url":"https://api.github.com/users/hunner/gists{/gist_id}","starred_url":"https://api.github.com/users/hunner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hunner/subscriptions","organizations_url":"https://api.github.com/users/hunner/orgs","repos_url":"https://api.github.com/users/hunner/repos","events_url":"https://api.github.com/users/hunner/events{/privacy}","received_events_url":"https://api.github.com/users/hunner/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-03-31T19:21:26Z","updated_at":"2015-05-12T00:16:59Z","closed_at":null,"body":"This line: https://github.com/rodjek/rspec-puppet/blob/v2.0.1/lib/rspec-puppet/support.rb#L145\r\n\r\nConflicts with this line: https://github.com/puppetlabs/puppet/blob/4.0.0-rc2/lib/puppet/defaults.rb#L255\r\n\r\nBecause `$LOAD_PATH` is supposed to be an array of lib directories, but if `Puppet[:libdir]` is a colon-separated list of directories, then this falls over and breaks `require` from fixtures. This eventually trickles down to https://github.com/puppetlabs/puppet/blob/4.0.0-rc2/lib/puppet/util/autoload.rb#L161 and broken load paths.\r\n\r\nThe solution would need rspec-puppet not use `Puppet[:libdir]`. I'm not sure of a hook that works yet, but perhaps something like `$LOAD_PATH` directly? Or letting the autoloader do its thing with `Puppet[:modulepath]` on its own."},"comment":{"url":"https://api.github.com/repos/rodjek/rspec-puppet/issues/comments/101079772","html_url":"https://github.com/rodjek/rspec-puppet/issues/264#issuecomment-101079772","issue_url":"https://api.github.com/repos/rodjek/rspec-puppet/issues/264","id":101079772,"user":{"login":"joshcooper","id":737664,"avatar_url":"https://avatars.githubusercontent.com/u/737664?v=3","gravatar_id":"","url":"https://api.github.com/users/joshcooper","html_url":"https://github.com/joshcooper","followers_url":"https://api.github.com/users/joshcooper/followers","following_url":"https://api.github.com/users/joshcooper/following{/other_user}","gists_url":"https://api.github.com/users/joshcooper/gists{/gist_id}","starred_url":"https://api.github.com/users/joshcooper/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joshcooper/subscriptions","organizations_url":"https://api.github.com/users/joshcooper/orgs","repos_url":"https://api.github.com/users/joshcooper/repos","events_url":"https://api.github.com/users/joshcooper/events{/privacy}","received_events_url":"https://api.github.com/users/joshcooper/received_events","type":"User","site_admin":false},"created_at":"2015-05-12T00:16:59Z","updated_at":"2015-05-12T00:16:59Z","body":"When puppet starts up, its bootstrapping process can result in the autoloader being called before the modulepath is known. So this is why the [autoloader roughly does](https://github.com/puppetlabs/puppet/blob/master/lib/puppet/util/autoload.rb#L127-L143):\r\n\r\n```\r\nif Puppet.settings.app_defaults_initialized?\r\n  # if the app defaults have been initialized then it should be safe to access the module path setting.\r\n  $env_module_directories[env] ||= env.modulepath.collect do |dir|\r\n   ..\r\n  end\r\nelse\r\n  # if we get here, the app defaults have not been initialized, so we basically use an empty module path.\r\n  []\r\nend\r\n```\r\n\r\nCalling `Puppet.settings.initialize_app_defaults` tells puppet that its settings have been parsed, its `run_mode` is known, and the bootstrapping process is done. And it allows the autoloader to load from the current environment's modulepath.\r\n\r\nThat said, there are two problem with that approach. First, it will only work if you load a custom type, provider, etc from a module, but not if that code attempts to `require` helper code from the same or different module.\r\n\r\nSecond, puppet's [`Puppet::Test::TestHelper`](https://github.com/puppetlabs/puppet/blob/master/lib/puppet/test/test_helper.rb) is intended to be the entry point when testing puppet as a library. For example, the `TestHelper` calls [`initialize_app_defaults`](https://github.com/puppetlabs/puppet/blob/master/lib/puppet/test/test_helper.rb#L211), as well as a bunch of other test initialization, e.g. pushing an environment onto the context stack.\r\n\r\nPuppet's own [spec_helper](https://github.com/puppetlabs/puppet/blob/master/spec/spec_helper.rb) calls into `Puppet::Test::TestHelper` to handle initialization. See https://github.com/puppetlabs/puppet/blob/master/spec/spec_helper.rb#L79, https://github.com/puppetlabs/puppet/blob/master/spec/spec_helper.rb#L99, https://github.com/puppetlabs/puppet/blob/master/spec/spec_helper.rb#L144, etc.\r\n\r\nI'm thinking rspec-puppet should be doing the same?\r\n\r\nFor this specific issue (colon separated `Puppet[:libdir]`), I have submitted https://github.com/rodjek/rspec-puppet/pull/237. It adds the current environment's module lib directories to the $LOAD_PATH, which works for custom types, etc, and helper code that they may require."}}