On Tue, Sep 18, 2012 at 1:46 PM, Jeff McCune <j...@puppetlabs.com> wrote:
> On Tue, Sep 18, 2012 at 10:15 AM, Mitchell Hashimoto < > mitchell.hashim...@gmail.com> wrote: > >> Thanks! This looks like basically what I was planning on doing, so it is >> good to see that this works. >> > > I'm glad. > > >> Can you expand on how #4248 is worked around by your pull? >> > > Sure, the issue is that the lib sub-directory of a puppet module isn't > added to Ruby's $LOAD_PATH. This means a regular `require "foo/bar"` won't > find <modulepath>/<mymodule>/lib/foo/bar.rb and a LoadError will be raised. > > To work around this problem, my patch first tries the plain `require > "foo/bar"` and catches any LoadErrors that are raised. I do this first > because I expect #4248 to be fixed in the future which will make `require > "foo/bar"` work as I expect it to. > > When I catch the load error, I try again, but this time I use the special > __FILE__ variable to get the full path of the ruby file being executed, get > the dirname, then construct an absolute path to the file I'm actually > trying to load. > > If this second absolute path attempt fails then the exception will be > raised normally. > > All of this is happening here: > > > https://github.com/jeffmccune/puppetlabs-registry/blob/67b7ffd8d973d50b8baf987eee4324c220d936db/lib/puppet/provider/registry_key/registry.rb#L2-12 > > The comment, "# Work around #7788 (Rubygems support for modules)" really > should say "Work around #4248 and #7788" > > In Telly (Puppet 3.0.0), we support plugins distributed as rubygems, so > `require "foo/bar"` will work in this scenario, but only if the plugin is > inside of a Gem. In this case, it's not, it's inside of a puppet module. > > Most of my modules are distributed using rsync onto a puppetmaster and not via gems. In this case, then, I still need to use __FILE__ and so on right? Or does Puppet 3.0.0 add those files to the load path as well? > -Jeff > > -- > You received this message because you are subscribed to the Google Groups > "Puppet Users" group. > To post to this group, send email to puppet-users@googlegroups.com. > To unsubscribe from this group, send email to > puppet-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/puppet-users?hl=en. > -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.