puppet4 stdlib (4.12.0) error with .find method?

85 views
Skip to first unread message

Matthew Pounsett

unread,
Sep 7, 2016, 2:58:39 PM9/7/16
to Puppet Users

Having just installed zleslie/pkgng in order to ma nage repositories on my FreeBSD hosts (which in turn required and installed puppetlabs/stdlib), I'm now getting the following error from my puppet runs:

% sudo puppet agent -t
Info: Using configured environment 'production'
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Loading facts
Info: Caching catalog for puppet.localdomain
Info: Applying configuration version '1473274285'
Error: Failed to apply catalog: undefined method `find' for nil:NilClass

I've checked, and the only place where a find method is called, anywhere, is within stdlib in the file_line provider and resource, and in the get_module_path function.

% sudo find . -type f |xargs fgrep -l .find    

./modules/stdlib/lib/puppet/provider/file_line/ruby.rb

./modules/stdlib/lib/puppet/parser/functions/get_module_path.rb

./modules/stdlib/spec/unit/puppet/type/file_line_spec.rb


The only one of these called from outside of stdlib is file_line, and it's called by zleslie/pkgng:

% sudo find . -type f |xargs egrep -l '(file_line|get_module_path)'
./modules/stdlib/CHANGELOG.md
./modules/stdlib/examples/file_line.pp
./modules/stdlib/lib/puppet/provider/file_line/ruby.rb
./modules/stdlib/lib/puppet/type/file_line.rb
./modules/stdlib/lib/puppet/parser/functions/load_module_metadata.rb
./modules/stdlib/lib/puppet/parser/functions/get_module_path.rb
./modules/stdlib/spec/acceptance/get_module_path_spec.rb
./modules/stdlib/spec/functions/load_module_metadata_spec.rb
./modules/stdlib/spec/functions/get_module_path_spec.rb
./modules/stdlib/spec/unit/puppet/type/file_line_spec.rb
./modules/stdlib/spec/unit/puppet/provider/file_line/ruby_spec.rb
./modules/stdlib/README.markdown
./modules/stdlib/checksums.json
./modules/pkgng/manifests/init.pp

I've tried temporarily commenting out the call to file_line that appears in the pkgng module, and that does not make the error go away.

I'm left with the conclusion that there's a bug in stdlib, but the lack of debug output makes this hard to track down.   Anyone have any suggestions for further nailing down which use of 'find' is the error?  

Or is this a known bug?


Henrik Lindberg

unread,
Sep 7, 2016, 7:11:04 PM9/7/16
to puppet...@googlegroups.com
The call to `find` is in Ruby, not in puppet. There are numerous calls
to find in the Ruby code base.
To find where the error is run the compilation with --trace and look at
the logged exception - it will tell you where in Ruby the error
occurred. From there is should be able to trace backwards.

If you are on the latest 4.x the backtrace will include puppet function
calls as well as Ruby methods to make this easier.

The error:
Error: Failed to apply catalog: undefined method `find' for nil:NilClass

may come from an `undef` value (translated to Ruby nil in Ruby if you
are using future parser or 4.x)

Hope this helps pin down where the problem is.

Regards,
- henrik

> Or is this a known bug?
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "Puppet Users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to puppet-users...@googlegroups.com
> <mailto:puppet-users...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/puppet-users/4babef51-20d7-4375-9be8-d210874b2534%40googlegroups.com
> <https://groups.google.com/d/msgid/puppet-users/4babef51-20d7-4375-9be8-d210874b2534%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout.


--

Visit my Blog "Puppet on the Edge"
http://puppet-on-the-edge.blogspot.se/

Matthew Pounsett

unread,
Sep 7, 2016, 11:34:53 PM9/7/16
to Puppet Users


On Wednesday, 7 September 2016 19:11:04 UTC-4, Henrik Lindberg wrote:

The call to `find` is in Ruby, not in puppet. There are numerous calls
to find in the Ruby code base.

Yeah, all the stuff I was looking at was ruby.  It hadn't occurred to me to check the puppet codebase itself though. 
 
To find where the error is run the compilation with --trace and look at
the logged exception - it will tell you where in Ruby the error
occurred. From there is should be able to trace backwards.

Aha.. --trace is a big help there.  It looks like a bug in the pkgng provider, possibly?
 

If you are on the latest 4.x the backtrace will include puppet function
calls as well as Ruby methods to make this easier.

I'm running 4.5.1.  It doesn't look like the puppet calls were included, to me.  
 

The error:
   Error: Failed to apply catalog: undefined method `find' for nil:NilClass

may come from an `undef` value (translated to Ruby nil in Ruby if you
are using future parser or 4.x)

Hope this helps pin down where the problem is.

Yeah, I think I found it.   zleslie/pkgng failed to create the repository config I asked it to, while deleting the pre-existing default repository (I had purge_repos_d set to true).  It looks like in the absence of a functioning repository, the pkgng provider fails to handle the condition of there being no available packages to install, or even list.

Thanks for your help!

% sudo puppet agent -t --trace
Info: Using configured environment 'production'
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Loading facts
Info: Caching catalog for puppet.localdomain
Info: Applying configuration version '1473304882'

Error: Failed to apply catalog: undefined method
`find' for nil:NilClass
/usr/local/lib/ruby/site_ruby/2.2/puppet/provider/package/pkgng.rb:66:in `
block in prefetch'
/usr/local/lib/ruby/site_ruby/2.2/puppet/provider/package/pkgng.rb:65:in `each'

/usr/local/lib/ruby/site_ruby/2.2/puppet/provider/package/pkgng.rb:65:in `prefetch'
/usr/local/lib/ruby/site_ruby/2.2/puppet/transaction.rb:305:in `
prefetch'
/usr/local/lib/ruby/site_ruby/2.2/puppet/transaction.rb:205:in `prefetch_if_necessary'

/usr/local/lib/ruby/site_ruby/2.2/puppet/transaction.rb:97:in `block in evaluate'
/usr/local/lib/ruby/site_ruby/2.2/puppet/graph/relationship_graph.rb:116:in `
call'
/usr/local/lib/ruby/site_ruby/2.2/puppet/graph/relationship_graph.rb:116:in `traverse'

/usr/local/lib/ruby/site_ruby/2.2/puppet/transaction.rb:142:in `evaluate'
/usr/local/lib/ruby/site_ruby/2.2/puppet/resource/catalog.rb:222:in `
block in apply'
/usr/local/lib/ruby/site_ruby/2.2/puppet/util/log.rb:155:in `with_destination'

/usr/local/lib/ruby/site_ruby/2.2/puppet/transaction/report.rb:118:in `as_logging_destination'
/usr/local/lib/ruby/site_ruby/2.2/puppet/resource/catalog.rb:221:in `
apply'
/usr/local/lib/ruby/site_ruby/2.2/puppet/configurer.rb:171:in `block in apply_catalog'

/usr/local/lib/ruby/site_ruby/2.2/puppet/util.rb:223:in `block in benchmark'
/usr/local/lib/ruby/2.2/benchmark.rb:303:in `
realtime'
/usr/local/lib/ruby/site_ruby/2.2/puppet/util.rb:222:in `benchmark'

/usr/local/lib/ruby/site_ruby/2.2/puppet/configurer.rb:170:in `apply_catalog'
/usr/local/lib/ruby/site_ruby/2.2/puppet/configurer.rb:315:in `
run_internal'
/usr/local/lib/ruby/site_ruby/2.2/puppet/configurer.rb:186:in `block in run'

/usr/local/lib/ruby/site_ruby/2.2/puppet/context.rb:65:in `override'
/usr/local/lib/ruby/site_ruby/2.2/puppet.rb:240:in `
override'
/usr/local/lib/ruby/site_ruby/2.2/puppet/configurer.rb:185:in `run'

/usr/local/lib/ruby/site_ruby/2.2/puppet/agent.rb:45:in `block (4 levels) in run'
/usr/local/lib/ruby/site_ruby/2.2/puppet/agent/locker.rb:21:in `
lock'
/usr/local/lib/ruby/site_ruby/2.2/puppet/agent.rb:45:in `block (3 levels) in run'

/usr/local/lib/ruby/site_ruby/2.2/puppet/agent.rb:98:in `with_client'
/usr/local/lib/ruby/site_ruby/2.2/puppet/agent.rb:42:in `
block (2 levels) in run'
/usr/local/lib/ruby/site_ruby/2.2/puppet/agent.rb:65:in `run_in_fork'

/usr/local/lib/ruby/site_ruby/2.2/puppet/agent.rb:41:in `block in run'
/usr/local/lib/ruby/site_ruby/2.2/puppet/application.rb:179:in `
call'
/usr/local/lib/ruby/site_ruby/2.2/puppet/application.rb:179:in `controlled_run'

/usr/local/lib/ruby/site_ruby/2.2/puppet/agent.rb:39:in `run'
/usr/local/lib/ruby/site_ruby/2.2/puppet/application/agent.rb:353:in `
onetime'
/usr/local/lib/ruby/site_ruby/2.2/puppet/application/agent.rb:331:in `run_command'

/usr/local/lib/ruby/site_ruby/2.2/puppet/application.rb:344:in `block in run'
/usr/local/lib/ruby/site_ruby/2.2/puppet/util.rb:540:in `
exit_on_fail'
/usr/local/lib/ruby/site_ruby/2.2/puppet/application.rb:344:in `run'

/usr/local/lib/ruby/site_ruby/2.2/puppet/util/command_line.rb:128:in `run'
/usr/local/lib/ruby/site_ruby/2.2/puppet/util/command_line.rb:72:in `
execute'
/usr/local/bin/puppet:5:in `<main>'


Reply all
Reply to author
Forward
0 new messages