chocolatey / choco

Chocolatey - the package manager for Windows
https://chocolatey.org
Other
10.21k stars 896 forks source link

NoMethodError undefined method `chomp' for nil:NilClass #914

Closed jmilacek closed 7 years ago

jmilacek commented 8 years ago

What You Are Seeing?

Issue started after 8/11/16 update of https://chocolatey.org/packages/pstools

After chef run:

NoMethodError
undefined method `chomp' for nil:NilClass

What is Expected?

chocolately package installs

How Did You Get This To Happen? (Steps to Reproduce)

In chef code:

chocolatey_package 'pstools' do
action :install
end

Output Log

#<NoMethodError: chocolatey_package[pstools] (businessname-windows-packages::default line 101) had an error: NoMethodError: undefined method `chomp' for nil:NilClass> had an error:
chocolatey_package[pstools] (businessname-windows-packages::default line 101) had an error: NoMethodError: undefined method `chomp' for nil:NilClass
Description: Error executing action `install` on resource 'chocolatey_package[pstools]'
NoMethodError
undefined method `chomp' for nil:NilClass
Cookbook Trace:
c:/chef/cache/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/runner.rb:41:in `run_action'
Resource Declaration:
# In c:/chef/cache/cookbooks/businessname-windows-packages/recipes/default.rb

101: chocolatey_package 'pstools' do
102:   action :install
103: end
104: 
Compiled Resource:
# Declared in c:/chef/cache/cookbooks/businessname-windows-packages/recipes/default.rb:101:in `from_file'

chocolatey_package("pstools") do
  package_name ["pstools"]
  action [:install]
  retries 0
  retry_delay 2
  default_guard_interpreter :default
  declared_type :chocolatey_package
  cookbook_name "businessname-windows-packages"
  recipe_name "default"
end
Stacktrace
C:/opscode/chef/embedded/lib/ruby/gems/2.0.0/gems/chef-12.8.1-universal-mingw32/lib/chef/provider/package/chocolatey.rb:260:in `block in parse_list_output'
C:/opscode/chef/embedded/lib/ruby/gems/2.0.0/gems/chef-12.8.1-universal-mingw32/lib/chef/provider/package/chocolatey.rb:258:in `each_line'
C:/opscode/chef/embedded/lib/ruby/gems/2.0.0/gems/chef-12.8.1-universal-mingw32/lib/chef/provider/package/chocolatey.rb:258:in `parse_list_output'
C:/opscode/chef/embedded/lib/ruby/gems/2.0.0/gems/chef-12.8.1-universal-mingw32/lib/chef/provider/package/chocolatey.rb:234:in `available_packages'
C:/opscode/chef/embedded/lib/ruby/gems/2.0.0/gems/chef-12.8.1-universal-mingw32/lib/chef/provider/package/chocolatey.rb:181:in `block in build_candidate_versions'
C:/opscode/chef/embedded/lib/ruby/gems/2.0.0/gems/chef-12.8.1-universal-mingw32/lib/chef/provider/package/chocolatey.rb:180:in `map'
C:/opscode/chef/embedded/lib/ruby/gems/2.0.0/gems/chef-12.8.1-universal-mingw32/lib/chef/provider/package/chocolatey.rb:180:in `build_candidate_versions'
C:/opscode/chef/embedded/lib/ruby/gems/2.0.0/gems/chef-12.8.1-universal-mingw32/lib/chef/provider/package/chocolatey.rb:72:in `candidate_version'
C:/opscode/chef/embedded/lib/ruby/gems/2.0.0/gems/chef-12.8.1-universal-mingw32/lib/chef/provider/package.rb:471:in `candidate_version_array'
C:/opscode/chef/embedded/lib/ruby/gems/2.0.0/gems/chef-12.8.1-universal-mingw32/lib/chef/provider/package.rb:452:in `block in each_package'
C:/opscode/chef/embedded/lib/ruby/gems/2.0.0/gems/chef-12.8.1-universal-mingw32/lib/chef/provider/package.rb:451:in `each'
C:/opscode/chef/embedded/lib/ruby/gems/2.0.0/gems/chef-12.8.1-universal-mingw32/lib/chef/provider/package.rb:451:in `each_with_index'
C:/opscode/chef/embedded/lib/ruby/gems/2.0.0/gems/chef-12.8.1-universal-mingw32/lib/chef/provider/package.rb:451:in `each_package'
C:/opscode/chef/embedded/lib/ruby/gems/2.0.0/gems/chef-12.8.1-universal-mingw32/lib/chef/provider/package.rb:437:in `forced_packages_missing_candidates'
C:/opscode/chef/embedded/lib/ruby/gems/2.0.0/gems/chef-12.8.1-universal-mingw32/lib/chef/provider/package.rb:69:in `block in define_resource_requirements'
C:/opscode/chef/embedded/lib/ruby/gems/2.0.0/gems/chef-12.8.1-universal-mingw32/lib/chef/mixin/why_run.rb:314:in `assert'
C:/opscode/chef/embedded/lib/ruby/gems/2.0.0/gems/chef-12.8.1-universal-mingw32/lib/chef/provider/package.rb:67:in `define_resource_requirements'
C:/opscode/chef/embedded/lib/ruby/gems/2.0.0/gems/chef-12.8.1-universal-mingw32/lib/chef/provider/package/chocolatey.rb:53:in `define_resource_requirements'
C:/opscode/chef/embedded/lib/ruby/gems/2.0.0/gems/chef-12.8.1-universal-mingw32/lib/chef/provider.rb:131:in `run_action'
C:/opscode/chef/embedded/lib/ruby/gems/2.0.0/gems/chef-12.8.1-universal-mingw32/lib/chef/resource.rb:596:in `run_action'
c:/chef/cache/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/runner.rb:41:in `run_action'
C:/opscode/chef/embedded/lib/ruby/gems/2.0.0/gems/chef-12.8.1-universal-mingw32/lib/chef/runner.rb:105:in `block (2 levels) in converge'
C:/opscode/chef/embedded/lib/ruby/gems/2.0.0/gems/chef-12.8.1-universal-mingw32/lib/chef/runner.rb:105:in `each'
C:/opscode/chef/embedded/lib/ruby/gems/2.0.0/gems/chef-12.8.1-universal-mingw32/lib/chef/runner.rb:105:in `block in converge'
C:/opscode/chef/embedded/lib/ruby/gems/2.0.0/gems/chef-12.8.1-universal-mingw32/lib/chef/resource_collection/resource_list.rb:84:in `block in execute_each_resource'
C:/opscode/chef/embedded/lib/ruby/gems/2.0.0/gems/chef-12.8.1-universal-mingw32/lib/chef/resource_collection/stepable_iterator.rb:116:in `call'
C:/opscode/chef/embedded/lib/ruby/gems/2.0.0/gems/chef-12.8.1-universal-mingw32/lib/chef/resource_collection/stepable_iterator.rb:116:in `call_iterator_block'
C:/opscode/chef/embedded/lib/ruby/gems/2.0.0/gems/chef-12.8.1-universal-mingw32/lib/chef/resource_collection/stepable_iterator.rb:85:in `step'
C:/opscode/chef/embedded/lib/ruby/gems/2.0.0/gems/chef-12.8.1-universal-mingw32/lib/chef/resource_collection/stepable_iterator.rb:104:in `iterate'
C:/opscode/chef/embedded/lib/ruby/gems/2.0.0/gems/chef-12.8.1-universal-mingw32/lib/chef/resource_collection/stepable_iterator.rb:55:in `each_with_index'
C:/opscode/chef/embedded/lib/ruby/gems/2.0.0/gems/chef-12.8.1-universal-mingw32/lib/chef/resource_collection/resource_list.rb:82:in `execute_each_resource'
C:/opscode/chef/embedded/lib/ruby/gems/2.0.0/gems/chef-12.8.1-universal-mingw32/lib/chef/runner.rb:104:in `converge'
C:/opscode/chef/embedded/lib/ruby/gems/2.0.0/gems/chef-12.8.1-universal-mingw32/lib/chef/client.rb:668:in `block in converge'
C:/opscode/chef/embedded/lib/ruby/gems/2.0.0/gems/chef-12.8.1-universal-mingw32/lib/chef/client.rb:663:in `catch'
C:/opscode/chef/embedded/lib/ruby/gems/2.0.0/gems/chef-12.8.1-universal-mingw32/lib/chef/client.rb:663:in `converge'
C:/opscode/chef/embedded/lib/ruby/gems/2.0.0/gems/chef-12.8.1-universal-mingw32/lib/chef/client.rb:702:in `converge_and_save'
C:/opscode/chef/embedded/lib/ruby/gems/2.0.0/gems/chef-12.8.1-universal-mingw32/lib/chef/client.rb:280:in `run'
C:/opscode/chef/embedded/lib/ruby/gems/2.0.0/gems/chef-12.8.1-universal-mingw32/lib/chef/application.rb:252:in `run_with_graceful_exit_option'
C:/opscode/chef/embedded/lib/ruby/gems/2.0.0/gems/chef-12.8.1-universal-mingw32/lib/chef/application.rb:228:in `block in run_chef_client'
C:/opscode/chef/embedded/lib/ruby/gems/2.0.0/gems/chef-12.8.1-universal-mingw32/lib/chef/local_mode.rb:44:in `with_server_connectivity'
C:/opscode/chef/embedded/lib/ruby/gems/2.0.0/gems/chef-12.8.1-universal-mingw32/lib/chef/application.rb:211:in `run_chef_client'
C:/opscode/chef/embedded/lib/ruby/gems/2.0.0/gems/chef-12.8.1-universal-mingw32/lib/chef/application/client.rb:417:in `run_application'
C:/opscode/chef/embedded/lib/ruby/gems/2.0.0/gems/chef-12.8.1-universal-mingw32/lib/chef/application.rb:58:in `run'
C:/opscode/chef/embedded/lib/ruby/gems/2.0.0/gems/chef-12.8.1-universal-mingw32/bin/chef-client:26:in `<top (required)>'
C:/opscode/chef/bin/chef-client:60:in `load'
C:/opscode/chef/bin/chef-client:60:in `<main>'
ferventcoder commented 8 years ago

Need the log file from Chocolatey as well.

ferventcoder commented 8 years ago

So I see Chef 12.8.1. We'll need to know Chocolatey version, Windows version and PowerShell version.

cc @mwrock heads up.

mwrock commented 8 years ago

FYI this was fixed in a recent version of chef https://github.com/chef/chef/pull/4760. Not a bad idea though to update choco to work with older versions.

ferventcoder commented 8 years ago

@mwrock Still not even sure what the issue is.

mwrock commented 8 years ago

Not sure which version but somewhere between 0.9.10.2 and 0.10.0, choco started printing Chocolatey v0.X.X as the first line of output from choco list and other commands. That confused the chef parsing of packages and versions returned from that command and the fix was just to ignore that line.

jmilacek commented 8 years ago

I'm running Chocolatey v0.10.0. Windows Server 2012R2. PowerShell v5.

ferventcoder commented 8 years ago

Not sure which version but somewhere between 0.9.10.2 and 0.10.0, choco started printing Chocolatey v0.X.X as the first line of output from choco list and other commands. That confused the chef parsing of packages and versions returned from that command and the fix was just to ignore that line.

Even with -r?

mwrock commented 8 years ago

Ahh looking through the history it looks like thats when we were using -ar which has the line. We use -r now and no that omits the version line.

ferventcoder commented 8 years ago

Weird that -ar included the line, I imagine that the --all option is not a global configuration value, which means when -ar is evaluated as a blended option it errors and then later then -a is available, it configures -ar options appropriately, but only after having printed out Chocolatey vXX.XX

jmilacek commented 8 years ago

So it doesn't look like it was fixed in 0.10.0? That's what I'm running but it still does it.

ferventcoder commented 8 years ago

@blackdynamite595 the issue is your Chef version. Please upgrade as soon as possible as Chef was running incorrectly with Chocolatey. It's not something we can work around really (unfortunately due to how the version you have passed arguments to Chocolatey).

You can alternatively apply the patch that @mwrock linked to above.

ferventcoder commented 8 years ago

Or to put it another way, the bug is most likely in the version of Chef that you are currently using. If it turns out to be the same issue, that is what it is.

ferventcoder commented 7 years ago

Going to close this as not an issue with Chocolatey.

ferventcoder commented 7 years ago

Please feel free to comment if you feel there is a fix on the Chocolatey side for this.