Chocolatey pre-fetch fails with Puppet - Could not prefetch package provider 'chocolatey': undefined method `each' for nil:NilClass

1,377 views
Skip to first unread message

Jim Ficarra

unread,
Jun 17, 2014, 1:51:18 PM6/17/14
to puppet...@googlegroups.com
Chocolatey is installed as a shared module on the puppet master. Below is the specific part of the puppet code that uses the chocolatey provider to install a custom package.  


class install_carbon {
package {'carbon':
ensure => '1.7',
provider => 'chocolatey',
}
}


This class is part of a larger set of modules and classes that work together and execute completely and successfully on another host but fails on a second host with the error below.  Same puppet client version (3.4.2 installed from an internal NuGet repo).  Chocolatey is also customized to point to an internal repo.

Any help/thoughts/insight would be appreciated.

Thanks!

Could not prefetch package provider 'chocolatey': undefined method `each' for nil:NilClass
C:/Tools/Puppet/puppet/lib/puppet/provider/package.rb:4:in `prefetch'
C:/Tools/Puppet/puppet/lib/puppet/transaction.rb:277:in `prefetch'
C:/Tools/Puppet/puppet/lib/puppet/transaction.rb:167:in `prefetch_if_necessary'
C:/Tools/Puppet/puppet/lib/puppet/transaction.rb:67:in `block in evaluate'
C:/Tools/Puppet/puppet/lib/puppet/graph/relationship_graph.rb:116:in `call'
C:/Tools/Puppet/puppet/lib/puppet/graph/relationship_graph.rb:116:in `traverse'
C:/Tools/Puppet/puppet/lib/puppet/transaction.rb:108:in `evaluate'
C:/Tools/Puppet/puppet/lib/puppet/resource/catalog.rb:164:in `block in apply'
C:/Tools/Puppet/puppet/lib/puppet/util/log.rb:149:in `with_destination'
C:/Tools/Puppet/puppet/lib/puppet/transaction/report.rb:108:in `as_logging_destination'
C:/Tools/Puppet/puppet/lib/puppet/resource/catalog.rb:163:in `apply'
C:/Tools/Puppet/puppet/lib/puppet/configurer.rb:125:in `block in apply_catalog'
C:/Tools/Puppet/puppet/lib/puppet/util.rb:161:in `block in benchmark'
C:/Tools/Puppet/sys/ruby/lib/ruby/1.9.1/benchmark.rb:295:in `realtime'
C:/Tools/Puppet/puppet/lib/puppet/util.rb:160:in `benchmark'
C:/Tools/Puppet/puppet/lib/puppet/configurer.rb:124:in `apply_catalog'
C:/Tools/Puppet/puppet/lib/puppet/configurer.rb:192:in `run'
C:/Tools/Puppet/puppet/lib/puppet/agent.rb:44:in `block (4 levels) in run'
C:/Tools/Puppet/puppet/lib/puppet/agent/locker.rb:20:in `lock'
C:/Tools/Puppet/puppet/lib/puppet/agent.rb:44:in `block (3 levels) in run'
C:/Tools/Puppet/puppet/lib/puppet/agent.rb:114:in `with_client'
C:/Tools/Puppet/puppet/lib/puppet/agent.rb:41:in `block (2 levels) in run'
C:/Tools/Puppet/puppet/lib/puppet/agent.rb:79:in `run_in_fork'
C:/Tools/Puppet/puppet/lib/puppet/agent.rb:40:in `block in run'
C:/Tools/Puppet/puppet/lib/puppet/application.rb:179:in `call'
C:/Tools/Puppet/puppet/lib/puppet/application.rb:179:in `controlled_run'
C:/Tools/Puppet/puppet/lib/puppet/agent.rb:38:in `run'
C:/Tools/Puppet/puppet/lib/puppet/application/agent.rb:355:in `onetime'
C:/Tools/Puppet/puppet/lib/puppet/application/agent.rb:321:in `run_command'
C:/Tools/Puppet/puppet/lib/puppet/application.rb:364:in `block (2 levels) in run'
C:/Tools/Puppet/puppet/lib/puppet/application.rb:470:in `plugin_hook'
C:/Tools/Puppet/puppet/lib/puppet/application.rb:364:in `block in run'
C:/Tools/Puppet/puppet/lib/puppet/util.rb:478:in `exit_on_fail'
C:/Tools/Puppet/puppet/lib/puppet/application.rb:364:in `run'
C:/Tools/Puppet/puppet/lib/puppet/util/command_line.rb:137:in `run'
C:/Tools/Puppet/puppet/lib/puppet/util/command_line.rb:91:in `execute'
C:/Tools/Puppet/puppet/bin/puppet:4:in `<main>'

Rob Reynolds

unread,
Jun 17, 2014, 4:15:44 PM6/17/14
to puppet...@googlegroups.com
Let's make sure everything is set up correctly. Do you have chocolatey (the client tool) already installed on both of those servers? If so what versions of chocolatey?

Do they both respond to output? (choco /?)

Moving up the chain to the provider, let's execute puppet agent -td --verbose --trace
This should really get us to what might be causing the error.



--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/ed1ffcb8-f3da-4079-ae8b-d115a08f9d5a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Rob Reynolds
Developer, Puppet Labs

Join us at PuppetConf 2014September 20-24 in San Francisco
Register by July 31st to take advantage of the Early Bird discount save $249!

Jim Ficarra

unread,
Jun 17, 2014, 4:55:31 PM6/17/14
to puppet...@googlegroups.com
Hey Rob,
 
Thanks for the response!
 
Yes – chocolatey version 0.9.8.23 is installed on both servers (found via choco version).  They both respond to choco /?.  This is a customized version that has had the install path modified and the default repository restricted to an internal Nuget repository.
 
I can also install chocolatey packages manually on both servers – specifically this package that is failing by typing “cinst carbon”.
 
I am running puppet as a windows service and ran the service with debug/trace (sc start puppet –debug –trace) to pull the previous errors from the event log, though they were a bit segregated across event entries.

It's also worth noting that there are 4 resource types ahead of the one that's failing.  The 4 resourcs types (two files and two execs) are applied successfully.  I ran the puppet agent –td –verbose –trace and received a lot of output, but essentially the same errors that don't appear to have any new information.   The successful output shows that the 4 previous resource types ran.  

Included below is the start of when it begins to apply the package with the chocolatey provider:

Notice: /Stage[main]/Copy_externalfacts/Exec[BuildStatusFacterFile_SetPerms]/returns: executed successfully
Debug: /Stage[main]/Copy_externalfacts/Exec[BuildStatusFacterFile_SetPerms]: The container Class[Copy_externalfacts] will propagate my refresh event
Debug: Class[Copy_externalfacts]: The container Stage[main] will propagate my refresh event
Debug: Prefetching chocolatey resources for package
Debug: Executing 'C:\Tools\Chocolatey\chocolateyInstall\chocolatey.cmd list -lo'
Error: Could not prefetch package provider 'chocolatey': undefined method `each' for nil:NilClass
Debug: Executing 'C:\Tools\Chocolatey\chocolateyInstall\chocolatey.cmd list -lo'
Error: /Stage[main]/Install_carbon/Package[carbon]: Could not evaluate: undefined method `each' for nil:NilClass
C:/ProgramData/PuppetLabs/puppet/var/lib/puppet/provider/package/chocolatey.rb:66:in `query'
C:/Tools/Puppet/puppet/lib/puppet/provider/package.rb:19:in `properties'
C:/Tools/Puppet/puppet/lib/puppet/type/package.rb:178:in `retrieve'
C:/Tools/Puppet/puppet/lib/puppet/type.rb:1035:in `retrieve'
C:/Tools/Puppet/puppet/lib/puppet/type.rb:1063:in `retrieve_resource'
C:/Tools/Puppet/puppet/lib/puppet/transaction/resource_harness.rb:223:in `from_resource'
C:/Tools/Puppet/puppet/lib/puppet/transaction/resource_harness.rb:19:in `evaluate'
C:/Tools/Puppet/puppet/lib/puppet/transaction.rb:174:in `apply'
C:/Tools/Puppet/puppet/lib/puppet/transaction.rb:187:in `eval_resource'
C:/Tools/Puppet/puppet/lib/puppet/transaction.rb:117:in `call'
C:/Tools/Puppet/puppet/lib/puppet/transaction.rb:117:in `block (2 levels) in evaluate'
C:/Tools/Puppet/puppet/lib/puppet/util.rb:327:in `block in thinmark'
C:/Tools/Puppet/sys/ruby/lib/ruby/1.9.1/benchmark.rb:295:in `realtime'
C:/Tools/Puppet/puppet/lib/puppet/util.rb:326:in `thinmark'
C:/Tools/Puppet/puppet/lib/puppet/transaction.rb:117:in `block in evaluate'
C:/Tools/Puppet/puppet/lib/puppet/graph/relationship_graph.rb:118:in `traverse'
Notice: /Stage[main]/Install_iis/Windowsfeature[IIS]/Exec[add-feature-IIS]: Dependency Package[carbon] has failures: true
Warning: /Stage[main]/Install_iis/Windowsfeature[IIS]/Exec[add-feature-IIS]: Skipping because of failed dependencies

(list of failed dependencies go on)





Jim Ficarra

unread,
Jun 17, 2014, 5:25:55 PM6/17/14
to puppet...@googlegroups.com
Sorry if this is a duplicate – I tried to send earlier but it didn’t seem to hit the distro.
=====================================================================
 
Hey Rob,
 
Thanks for the response!
 
Yes – chocolatey version 0.9.8.23 is installed on both servers (found via choco version).  They both respond to choco /?.  This is a customized version that has had the install path modified and the default repository restricted to an internal Nuget repository.
 
I can also install chocolatey packages manually on both servers – specifically this package that is failing by typing “cinst carbon”.
 
I am running puppet as a windows service and ran the service with debug/trace (sc start puppet –debug –trace) to pull the previous errors from the event log, though they were a bit segregated across event entries.
 
It's also worth noting that there are 4 resource types ahead of the one that's failing.  The 4 resourcs types (two files and two execs) are applied successfully.  I ran the puppet agent –td –verbose –trace and received a lot of output, but essentially the same errors that don't appear to have any new information.   The successful output shows that the 4 previous resource types ran. 
 
Included below is the start of when it begins to apply the package with the chocolatey provider:
 
Notice: /Stage[main]/Copy_externalfacts/Exec[BuildStatusFacterFile_SetPerms]/returns: executed successfully
Debug: /Stage[main]/Copy_externalfacts/Exec[BuildStatusFacterFile_SetPerms]: The container Class[Copy_externalfacts] will propagate my refresh event
Debug: Class[Copy_externalfacts]: The container Stage[main] will propagate my refresh event
Debug: Prefetching chocolatey resources for package
Debug: Executing 'C:\Tools\Chocolatey\chocolateyInstall\chocolatey.cmd list -lo'
Error: Could not prefetch package provider 'chocolatey': undefined method `each' for nil:NilClass
Debug: Executing 'C:\Tools\Chocolatey\chocolateyInstall\chocolatey.cmd list -lo'
Error: /Stage[main]/Install_carbon/Package[carbon]: Could not evaluate: undefined method `each' for nil:NilClass
C:/ProgramData/PuppetLabs/puppet/var/lib/puppet/provider/package/chocolatey.rb:66:in `query'
C:/Tools/Puppet/puppet/lib/puppet/provider/package.rb:19:in `properties'
C:/Tools/Puppet/puppet/lib/puppet/type/package.rb:178:in `retrieve'
C:/Tools/Puppet/puppet/lib/puppet/type.rb:1035:in `retrieve'
C:/Tools/Puppet/puppet/lib/puppet/type.rb:1063:in `retrieve_resource'
C:/Tools/Puppet/puppet/lib/puppet/transaction/resource_harness.rb:223:in `from_resource'
C:/Tools/Puppet/puppet/lib/puppet/transaction/resource_harness.rb:19:in `evaluate'
C:/Tools/Puppet/puppet/lib/puppet/transaction.rb:174:in `apply'
C:/Tools/Puppet/puppet/lib/puppet/transaction.rb:187:in `eval_resource'
C:/Tools/Puppet/puppet/lib/puppet/transaction.rb:117:in `call'
C:/Tools/Puppet/puppet/lib/puppet/transaction.rb:117:in `block (2 levels) in evaluate'
C:/Tools/Puppet/puppet/lib/puppet/util.rb:327:in `block in thinmark'
C:/Tools/Puppet/sys/ruby/lib/ruby/1.9.1/benchmark.rb:295:in `realtime'
C:/Tools/Puppet/puppet/lib/puppet/util.rb:326:in `thinmark'
C:/Tools/Puppet/puppet/lib/puppet/transaction.rb:117:in `block in evaluate'
C:/Tools/Puppet/puppet/lib/puppet/graph/relationship_graph.rb:118:in `traverse'
Notice: /Stage[main]/Install_iis/Windowsfeature[IIS]/Exec[add-feature-IIS]: Dependency Package[carbon] has failures: true
Warning: /Stage[main]/Install_iis/Windowsfeature[IIS]/Exec[add-feature-IIS]: Skipping because of failed dependencies
 
(list of failed dependencies go on)
On Tue, Jun 17, 2014 at 4:15 PM, Rob Reynolds <r...@puppetlabs.com> wrote:

Jim Ficarra

unread,
Jun 17, 2014, 5:55:02 PM6/17/14
to puppet...@googlegroups.com
Sorry if this is a duplicate – I tried to send earlier but it didn’t seem to hit the distro. 
Also truncating it for readability
=====================================================================
 
Hey Rob,
 
Thanks for the response!
 
Yes – chocolatey version 0.9.8.23 is installed on both servers (found via choco version).  They both respond to choco /?.  This is a customized version that has had the install path modified and the default repository restricted to an internal Nuget repository.
 
I can also install chocolatey packages manually on both servers – specifically this package that is failing by typing “cinst carbon”.
 
I am running puppet as a windows service and ran the service with debug/trace (sc start puppet –debug –trace) to pull the previous errors from the event log, though they were a bit segregated across event entries.
 
It's also worth noting that there are 4 resource types ahead of the one that's failing.  The 4 resourcs types (two files and two execs) are applied successfully.  I ran the puppet agent –td –verbose –trace and received a lot of output, but essentially the same errors that don't appear to have any new information.   The successful output shows that the 4 previous resource types ran. 
 
Included below is the start of when it begins to apply the package with the chocolatey provider:
 
Notice: /Stage[main]/Copy_externalfacts/Exec[BuildStatusFacterFile_SetPerms]/returns: executed successfully
Debug: /Stage[main]/Copy_externalfacts/Exec[BuildStatusFacterFile_SetPerms]: The container Class[Copy_externalfacts] will propagate my refresh event
Debug: Class[Copy_externalfacts]: The container Stage[main] will propagate my refresh event
Debug: Prefetching chocolatey resources for package
Debug: Executing 'C:\Tools\Chocolatey\chocolateyInstall\chocolatey.cmd list -lo'
Error: Could not prefetch package provider 'chocolatey': undefined method `each' for nil:NilClass
C:/Tools/Puppet/puppet/lib/puppet/provider/package.rb:4:in `prefetch'
C:/Tools/Puppet/puppet/lib/puppet/transaction.rb:277:in `prefetch'
C:/Tools/Puppet/puppet/lib/puppet/transaction.rb:167:in `prefetch_if_necessary'
<truncated>
Debug: Executing 'C:\Tools\Chocolatey\chocolateyInstall\chocolatey.cmd list -lo'
Error: /Stage[main]/Install_carbon/Package[carbon]: Could not evaluate: undefined method `each' for nil:NilClass
C:/ProgramData/PuppetLabs/puppet/var/lib/puppet/provider/package/chocolatey.rb:66:in `query'
C:/Tools/Puppet/puppet/lib/puppet/provider/package.rb:19:in `properties'
C:/Tools/Puppet/puppet/lib/puppet/type/package.rb:178:in `retrieve'
C:/Tools/Puppet/puppet/lib/puppet/type.rb:1035:in `retrieve'
C:/Tools/Puppet/puppet/lib/puppet/type.rb:1063:in `retrieve_resource'
<truncated>

Rob Reynolds

unread,
Jun 23, 2014, 1:10:38 PM6/23/14
to puppet...@googlegroups.com
On Tue, Jun 17, 2014 at 3:55 PM, Jim Ficarra <jimfi...@gmail.com> wrote:
Hey Rob,
 
Thanks for the response!
 
Yes – chocolatey version 0.9.8.23 is installed on both servers (found via choco version).  They both respond to choco /?.  This is a customized version that has had the install path modified and the default repository restricted to an internal Nuget repository.
 
I can also install chocolatey packages manually on both servers – specifically this package that is failing by typing “cinst carbon”.

Are you using the puppet-chocolatey module from the forge or from github?
 

For more options, visit https://groups.google.com/d/optout.

Jim Ficarra

unread,
Jun 23, 2014, 1:48:34 PM6/23/14
to puppet...@googlegroups.com
It was installed on our puppet master which I don't control, so I'm not 100% sure - however this issue has been identified and fixed.  The issue boiled down to the PSModulePath system environment variable.  It was missing a semicolon between the stock path (%SystemRoot%\system32\WindowsPowerShell\v1.0\Modules\) and a new path I had put in earlier to point to a set of powershell modules.  

This got messed up in my ChocolateyUninstall.ps1 and instead of removing the ';c:\path\to\modules' I had added,the uninstall messed it up and just removed the semicolon.

The puppet master admins ended up putting in some debug code in the chocolatey provider ruby code (execpipe where it fetches the list of installed chocolatey packages via the provider pre-fetch) and it dumped out a powershell error that it couldn't find "split-path". The odd thing was that I could use split-path when opening up a powershell prompt while the PSModulePath was messed up.

This was a bit of a tough one to crack as the underlying powershell errors were masked behind the ruby.





Reply all
Reply to author
Forward
0 new messages