Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"undefined method `+' for false:FalseClass" when using package resources on CentOS 8 #8965

Closed
javier-lopez opened this issue Oct 7, 2019 · 6 comments · Fixed by #8972

Comments

@javier-lopez
Copy link

commented Oct 7, 2019

Description

yum_package fail to install packages on CentOS 8.

Chef Version

15.3.14

Platform Version

CentOS Linux release 8.0.1905 (Core)

Replication Case

Create a recipe that installs a package, for instance:

yum_package 'yum-utils' do
        action :install
end

Client Output

chef-apply yum.rb
Recipe: (chef-apply cookbook)::(chef-apply recipe)
  * yum_package[yum-utils] action install

    ================================================================================
    Error executing action `install` on resource 'yum_package[yum-utils]'
    ================================================================================

    NoMethodError
    -------------
    undefined method `+' for false:FalseClass

    Resource Declaration:
    ---------------------
    # In yum.rb

      1: yum_package 'yum-utils' do
      2:        action :install
      3: end

    Compiled Resource:
    ------------------
    # Declared in yum.rb:1:in `run_chef_recipe'

    yum_package("yum-utils") do
      package_name "yum-utils"
      action [:install]
      default_guard_interpreter :default
      declared_type :yum_package
      cookbook_name "(chef-apply cookbook)"
      recipe_name "(chef-apply recipe)"
    end

    System Info:
    ------------
    chef_version=15.3.14
    platform=centos
    platform_version=8.0.1905
    ruby=ruby 2.6.4p104 (2019-08-28 revision 67798) [x86_64-linux]
    program_name=/usr/bin/chef-apply
    executable=/opt/chef/bin/chef-apply

[2019-10-07T13:14:02-07:00] FATAL: Stacktrace dumped to /home/vagrant/.chef/cache/chef-stacktrace.out
[2019-10-07T13:14:02-07:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[2019-10-07T13:14:02-07:00] FATAL: NoMethodError: yum_package[yum-utils] ((chef-apply cookbook)::(chef-apply recipe) line 1) had an error: NoMethodError: undefined method `+' for false:FalseClass

There is a related issue: #7988

[vagrant@centos-80-x64 chef]$ python --version
-bash: python: command not found
[vagrant@centos-80-x64 chef]$ python2 --version
-bash: python2: command not found
[vagrant@centos-80-x64 chef]$ python3 --version
Python 3.6.8
[vagrant@centos-80-x64 chef]$ platform-python --version
-bash: platform-python: command not found
[vagrant@centos-80-x64 chef]$ /usr/libexec/platform-python --version
Python 3.6.8
[vagrant@centos-80-x64 chef]$ echo $PATH
/home/vagrant/.local/bin:/home/vagrant/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin

Stacktrace

cat /home/vagrant/.chef/cache/chef-stacktrace.out
Generated at 2019-10-07 13:36:11 -0700
NoMethodError: yum_package[yum-utils] ((chef-apply cookbook)::(chef-apply recipe) line 1) had an error: NoMethodError: undefined method `+' for false:FalseClass
/opt/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.3.14/lib/chef/provider/package/yum/python_helper.rb:45:in `yum_command'
/opt/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.3.14/lib/chef/provider/package/yum/python_helper.rb:52:in `start'
/opt/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.3.14/lib/chef/provider/package/yum/python_helper.rb:76:in `check'
/opt/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.3.14/lib/chef/provider/package/yum/python_helper.rb:197:in `block in with_helper'
/opt/chef/embedded/lib/ruby/2.6.0/timeout.rb:93:in `block in timeout'
/opt/chef/embedded/lib/ruby/2.6.0/timeout.rb:33:in `block in catch'
/opt/chef/embedded/lib/ruby/2.6.0/timeout.rb:33:in `catch'
/opt/chef/embedded/lib/ruby/2.6.0/timeout.rb:33:in `catch'
/opt/chef/embedded/lib/ruby/2.6.0/timeout.rb:108:in `timeout'
/opt/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.3.14/lib/chef/provider/package/yum/python_helper.rb:196:in `with_helper'
/opt/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.3.14/lib/chef/provider/package/yum/python_helper.rb:151:in `query'
/opt/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.3.14/lib/chef/provider/package/yum/python_helper.rb:117:in `package_query'
/opt/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.3.14/lib/chef/provider/package/yum.rb:243:in `installed_version'
/opt/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.3.14/lib/chef/provider/package/yum.rb:85:in `block in get_current_versions'
/opt/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.3.14/lib/chef/provider/package/yum.rb:84:in `each'
/opt/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.3.14/lib/chef/provider/package/yum.rb:84:in `each_with_index'
/opt/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.3.14/lib/chef/provider/package/yum.rb:84:in `each'
/opt/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.3.14/lib/chef/provider/package/yum.rb:84:in `map'
/opt/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.3.14/lib/chef/provider/package/yum.rb:84:in `get_current_versions'
/opt/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.3.14/lib/chef/provider/package/yum.rb:62:in `load_current_resource'
/opt/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.3.14/lib/chef/provider.rb:170:in `run_action'
/opt/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.3.14/lib/chef/resource.rb:585:in `run_action'
/opt/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.3.14/lib/chef/runner.rb:74:in `run_action'
/opt/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.3.14/lib/chef/runner.rb:108:in `block in run_all_actions'
/opt/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.3.14/lib/chef/runner.rb:108:in `each'
/opt/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.3.14/lib/chef/runner.rb:108:in `run_all_actions'
/opt/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.3.14/lib/chef/runner.rb:132:in `block in converge'
/opt/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.3.14/lib/chef/resource_collection/resource_list.rb:96:in `block in execute_each_resource'
/opt/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.3.14/lib/chef/resource_collection/stepable_iterator.rb:115:in `call_iterator_block'
/opt/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.3.14/lib/chef/resource_collection/stepable_iterator.rb:86:in `step'
/opt/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.3.14/lib/chef/resource_collection/stepable_iterator.rb:104:in `iterate'
/opt/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.3.14/lib/chef/resource_collection/stepable_iterator.rb:55:in `each_with_index'
/opt/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.3.14/lib/chef/resource_collection/resource_list.rb:94:in `execute_each_resource'
/opt/chef/embedded/lib/ruby/2.6.0/forwardable.rb:230:in `execute_each_resource'
/opt/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.3.14/lib/chef/runner.rb:130:in `converge'
/opt/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.3.14/lib/chef/application/apply.rb:199:in `block in run_chef_recipe'
/opt/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.3.14/lib/chef/application/apply.rb:197:in `catch'
/opt/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.3.14/lib/chef/application/apply.rb:197:in `run_chef_recipe'
/opt/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.3.14/lib/chef/application/apply.rb:209:in `run_application'
/opt/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.3.14/lib/chef/application/apply.rb:222:in `run'
/opt/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-bin-15.3.14/bin/chef-apply:24:in `<top (required)>'
/usr/bin/chef-apply:163:in `load'
/usr/bin/chef-apply:163:in `<main>'

>>>> Caused by NoMethodError: undefined method `+' for false:FalseClass
/opt/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.3.14/lib/chef/provider/package/yum/python_helper.rb:45:in `yum_command'
/opt/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.3.14/lib/chef/provider/package/yum/python_helper.rb:52:in `start'
/opt/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.3.14/lib/chef/provider/package/yum/python_helper.rb:76:in `check'
/opt/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.3.14/lib/chef/provider/package/yum/python_helper.rb:197:in `block in with_helper'
/opt/chef/embedded/lib/ruby/2.6.0/timeout.rb:93:in `block in timeout'
/opt/chef/embedded/lib/ruby/2.6.0/timeout.rb:33:in `block in catch'
/opt/chef/embedded/lib/ruby/2.6.0/timeout.rb:33:in `catch'
/opt/chef/embedded/lib/ruby/2.6.0/timeout.rb:33:in `catch'
/opt/chef/embedded/lib/ruby/2.6.0/timeout.rb:108:in `timeout'
/opt/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.3.14/lib/chef/provider/package/yum/python_helper.rb:196:in `with_helper'
/opt/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.3.14/lib/chef/provider/package/yum/python_helper.rb:151:in `query'
/opt/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.3.14/lib/chef/provider/package/yum/python_helper.rb:117:in `package_query'
/opt/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.3.14/lib/chef/provider/package/yum.rb:243:in `installed_version'
/opt/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.3.14/lib/chef/provider/package/yum.rb:85:in `block in get_current_versions'
/opt/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.3.14/lib/chef/provider/package/yum.rb:84:in `each'
/opt/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.3.14/lib/chef/provider/package/yum.rb:84:in `each_with_index'
/opt/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.3.14/lib/chef/provider/package/yum.rb:84:in `each'
/opt/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.3.14/lib/chef/provider/package/yum.rb:84:in `map'
/opt/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.3.14/lib/chef/provider/package/yum.rb:84:in `get_current_versions'
/opt/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.3.14/lib/chef/provider/package/yum.rb:62:in `load_current_resource'
/opt/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.3.14/lib/chef/provider.rb:170:in `run_action'
/opt/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.3.14/lib/chef/resource.rb:585:in `run_action'
/opt/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.3.14/lib/chef/runner.rb:74:in `run_action'
/opt/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.3.14/lib/chef/runner.rb:108:in `block in run_all_actions'
/opt/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.3.14/lib/chef/runner.rb:108:in `each'
/opt/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.3.14/lib/chef/runner.rb:108:in `run_all_actions'
/opt/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.3.14/lib/chef/runner.rb:132:in `block in converge'
/opt/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.3.14/lib/chef/resource_collection/resource_list.rb:96:in `block in execute_each_resource'
/opt/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.3.14/lib/chef/resource_collection/stepable_iterator.rb:115:in `call_iterator_block'
/opt/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.3.14/lib/chef/resource_collection/stepable_iterator.rb:86:in `step'
/opt/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.3.14/lib/chef/resource_collection/stepable_iterator.rb:104:in `iterate'
/opt/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.3.14/lib/chef/resource_collection/stepable_iterator.rb:55:in `each_with_index'
/opt/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.3.14/lib/chef/resource_collection/resource_list.rb:94:in `execute_each_resource'
/opt/chef/embedded/lib/ruby/2.6.0/forwardable.rb:230:in `execute_each_resource'
/opt/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.3.14/lib/chef/runner.rb:130:in `converge'
/opt/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.3.14/lib/chef/application/apply.rb:199:in `block in run_chef_recipe'
/opt/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.3.14/lib/chef/application/apply.rb:197:in `catch'
/opt/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.3.14/lib/chef/application/apply.rb:197:in `run_chef_recipe'
/opt/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.3.14/lib/chef/application/apply.rb:209:in `run_application'
/opt/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.3.14/lib/chef/application/apply.rb:222:in `run'
/opt/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-bin-15.3.14/bin/chef-apply:24:in `<top (required)>'
/usr/bin/chef-apply:163:in `load'
@lamont-granquist

This comment has been minimized.

Copy link
Contributor

commented Oct 8, 2019

What does /usr/libexec/platform-python -c 'import dnf' return?

@vsingh-msys

This comment has been minimized.

Copy link
Contributor

commented Oct 8, 2019

/usr/libexec/platform-python -c 'import dnf' return nothing seems it working fine

but the problem is when it's trying to import yum package.

#> /usr/libexec/platform-python -c 'import yum'

Traceback (most recent call last):
  File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'yum'
@lamont-granquist

This comment has been minimized.

Copy link
Contributor

commented Oct 8, 2019

yeah rhel8 doesn't have yum libraries so yum doesn't work and yum_package doesn't work. that isn't really a bug except for maybe having a better error message.

i think there are rpms that you can install even on rhel8 to get some kinds of backcompat with yum, but you shouldn't.

the fact that dnf_package doesn't work (and you seem to be reporting that it is wiring up the package provider to the yum_package provider) is the buggier part.

but i'm a bit suspicious that you've got some kind of horribly stripped down image without the right python libs and/or dnf itself, which will be hopeless and not a bug.

@javier-lopez

This comment has been minimized.

Copy link
Author

commented Oct 8, 2019

I get the same output as @vsingh-msys , no issue with dnf but a problem with yum, since rhel8/centos8 don't bring such libraries (and it's a bad idea to try to force its installation) then yum_package won't work in such platforms, I'm rewriting the recipe using the execute resource, thank you for the clarification!

@lamont-granquist

This comment has been minimized.

Copy link
Contributor

commented Oct 8, 2019

but dnf_package should work and you shouldn't use execute resources, that'll have terrible performance among other issues. do you have the dnf executable installed? (/usr/bin/dnf or whatever?)

NEVERMIND: i got this issue confused with #7988

@javier-lopez

This comment has been minimized.

Copy link
Author

commented Oct 9, 2019

@lamont-granquist indeed, I've reviewed the chef documentation and it states package should be used whenever possible, I've done some testing and internally it uses dnf_package which is working ok in centos 8, therefore I'm closing this issue, if I could add anything I would say that I agree, the message in yum_package could improve, maybe suggesting to use package or dnf_package as alternatives.

Thank you for you help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.