theforeman / hammer-cli-foreman-puppet

Adds Puppet functionality for Hammer Foreman CLI
Other
1 stars 10 forks source link

<NoMethodError> undefined method `singular_name' for nil:NilClass #43

Closed anesterova closed 2 years ago

anesterova commented 2 years ago

Fresh installation:

CentOS Linux release 7.9.2009 (Core)

tfm-rubygem-hammer_cli_foreman_puppet-0.0.4-1.fm3_1.el7.noarch
tfm-rubygem-hammer_cli_foreman_templates-0.2.0-2.fm2_5.el7.noarch
tfm-rubygem-hammer_cli_foreman-3.2.0-1.20220214175114git323f240.el7.noarch
tfm-rubygem-hammer_cli_foreman_admin-1.1.0-1.fm2_6.el7.noarch
tfm-rubygem-hammer_cli_foreman_webhooks-0.0.2-1.fm3_0.el7.noarch 

foreman-vmware-3.2.0-1.el7.noarch
foreman-release-3.2.0-1.el7.noarch
tfm-rubygem-foreman_discovery-20.0.1-1.fm3_2.el7.noarch
foreman-selinux-2.5.4-1.el7.noarch
foreman-debug-2.5.4-1.el7.noarch
foreman-service-3.2.0-1.el7.noarch
tfm-rubygem-puppetdb_foreman-5.0.0-3.fm2_5.el7.noarch
tfm-rubygem-foreman_dhcp_browser-0.0.8-5.fm2_5.el7.noarch
foreman-postgresql-3.2.0-1.el7.noarch
tfm-rubygem-foreman_puppet-3.0.5-1.fm3_2.el7.noarch
foreman-3.2.0-1.el7.noarch
foreman-proxy-3.2.0-1.el7.noarch

Full stack trace:

[ERROR 2022-04-18T09:01:40 Modules] Error while loading module hammer_cli_foreman_puppet.
[ERROR 2022-04-18T09:01:40 Modules] <NoMethodError> undefined method `singular_name' for nil:NilClass
        /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman_puppet-0.0.4/lib/hammer_cli_foreman_puppet/id_resolver.rb:78:in `for'
        /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-3.2.0/lib/hammer_cli_foreman/option_builders.rb:223:in `dependent_options'
        /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-3.2.0/lib/hammer_cli_foreman/option_builders.rb:216:in `build'
        /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-3.2.0/lib/hammer_cli/option_builder.rb:27:in `block in build'
        /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-3.2.0/lib/hammer_cli/option_builder.rb:26:in `each'
        /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-3.2.0/lib/hammer_cli/option_builder.rb:26:in `build'
        /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-3.2.0/lib/hammer_cli_foreman/option_builders.rb:129:in `build'
        /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-3.2.0/lib/hammer_cli/abstract.rb:237:in `build_options'
        /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-3.2.0/lib/hammer_cli_foreman/commands.rb:125:in `build_options'
        /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman_puppet-0.0.4/lib/hammer_cli_foreman_puppet/smart_class_parameter.rb:90:in `<class:InfoCommand>'
        /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman_puppet-0.0.4/lib/hammer_cli_foreman_puppet/smart_class_parameter.rb:55:in `<class:SmartClassParameter>'
        /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman_puppet-0.0.4/lib/hammer_cli_foreman_puppet/smart_class_parameter.rb:39:in `<module:HammerCLIForemanPuppet>'
        /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman_puppet-0.0.4/lib/hammer_cli_foreman_puppet/smart_class_parameter.rb:1:in `<top (required)>'
        /opt/rh/rh-ruby27/root/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:83:in `require'
        /opt/rh/rh-ruby27/root/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:83:in `require'
        /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman_puppet-0.0.4/lib/hammer_cli_foreman_puppet.rb:15:in `<module:HammerCLIForemanPuppet>'
        /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman_puppet-0.0.4/lib/hammer_cli_foreman_puppet.rb:1:in `<top (required)>'
        /opt/rh/rh-ruby27/root/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:158:in `require'
        /opt/rh/rh-ruby27/root/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:158:in `rescue in require'
        /opt/rh/rh-ruby27/root/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:147:in `require'
        /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-3.2.0/lib/hammer_cli/modules.rb:75:in `require_module'
        /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-3.2.0/lib/hammer_cli/modules.rb:54:in `load!'
        /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-3.2.0/lib/hammer_cli/modules.rb:69:in `load'
        /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-3.2.0/lib/hammer_cli/modules.rb:80:in `block in load_all'
        /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-3.2.0/lib/hammer_cli/modules.rb:79:in `each'
        /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-3.2.0/lib/hammer_cli/modules.rb:79:in `load_all'
        /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-3.2.0/bin/hammer:134:in `<top (required)>'
        /bin/hammer:23:in `load'
        /bin/hammer:23:in `<main>'
         --- Caused by ---
        <LoadError> cannot load such file -- hammer_cli_foreman_puppet
        /opt/rh/rh-ruby27/root/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:83:in `require'
        /opt/rh/rh-ruby27/root/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:83:in `require'
        /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-3.2.0/lib/hammer_cli/modules.rb:75:in `require_module'
        /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-3.2.0/lib/hammer_cli/modules.rb:54:in `load!'
        /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-3.2.0/lib/hammer_cli/modules.rb:69:in `load'

Same error using latest gems. Please advise

nadjaheitmann commented 2 years ago

@anesterova Thank you for reporting. Which command did you try to execute?

anesterova commented 2 years ago

hey @nadjaheitmann that was regular hammer -h

nadjaheitmann commented 2 years ago

@ofedoren Do you know if this is something fixed in hammer-cli-foreman-puppet 0.0.5? I didn't realize it was not packaged until I saw your packaging PR the other day.

nadjaheitmann commented 2 years ago

@anesterova You could try installing https://yum.theforeman.org/plugins/nightly/el7/x86_64/tfm-rubygem-hammer_cli_foreman_puppet-0.0.5-1.fm3_3.el7.noarch.rpm and see if it fixes your issue.

ofedoren commented 2 years ago

@anesterova, @nadjaheitmann, I can't reproduce the issue on my setup, but it seems like a fresh installation problem I've already heard about and simple hammer --reload-cache should fix it. Hopefully after https://github.com/theforeman/hammer-cli-foreman/pull/599 nobody will encounter this error again...

P.S. hammer-cli-foreman-puppet 0.0.5 fixed compatibility with hammer-cli-foreman-discovery plugin, nothing more.

anesterova commented 2 years ago

hey @ofedoren i was able to fix by running these commands:

foreman-rake apipie:cache
foreman-rake apipie:cache:index
hammer -r

This issue can be closed, ty!