Description of problem: hammer command completion not working on the shell. Version-Release number of selected component (if applicable): tfm-rubygem-hammer_cli-2.3.0-1.el7sat.noarch How reproducible: Always Steps to Reproduce: 1.Tab command completion does not work in hammer shell Actual results: Command completion does not work in hammer shell Expected results: Command completion should work in hammer shell Additional info: Red Hat Enterprise Linux Server release 7.9 (Maipo) hammer --version hammer (2.3.0) * hammer_cli_foreman (2.3.1) * hammer_cli_foreman_admin (1.0.0) * hammer_cli_foreman_ansible (0.3.2) * hammer_cli_foreman_azure_rm (0.2.0) * hammer_cli_foreman_bootdisk (0.3.0) * hammer_cli_foreman_discovery (1.0.2) * hammer_cli_foreman_docker (0.0.7) * hammer_cli_foreman_openscap (0.1.12) * hammer_cli_foreman_remote_execution (unknown version) * hammer_cli_foreman_tasks (unknown version) * hammer_cli_foreman_templates (0.2.0) * hammer_cli_foreman_virt_who_configure (unknown version) * hammer_cli_katello (0.24.0.2)
When trying completion on hammer with double tab it reports an error # hammer (tab)[tab] environment command is deprecated and will be removed in one of the future versions. Please use puppet-environment command instead. report command is deprecated and will be removed in one of the future versions. Please use config-report command instead. Error: undefined method `singular_name' for nil:NilClass environment command is deprecated and will be removed in one of the future versions. Please use puppet-environment command instead. report command is deprecated and will be removed in one of the future versions. Please use config-report command instead. Error: undefined method `singular_name' for nil:NilClass # hammer-complete environment command is deprecated and will be removed in one of the future versions. Please use puppet-environment command instead. report command is deprecated and will be removed in one of the future versions. Please use config-report command instead. Error: undefined method `singular_name' for nil:NilClass
Do you have a reproducer that we can access? We are no longer seeing this issue on our 6.10 configuration. Thanks!
In addition to what Brad said, have you tried the following: 1. Re-generate API docs: foreman-rake apipie:cache 2. Update hammer's cache: hammer --reload-cache 3. Re-build completion: hammer prebuild-bash-completion
Hm, I've tried hard to reproduce it, but unfortunatelly couldn't make it. Does this error occurre only in bash completion or this error is also shown when you try to run the actual command typed without completion? If this error occurres even without completion context, could you please share the debug log?
Actually, it could help if you run hammer full-help command to see if there any failures. If they are, please provide the debug output.
All the options are printed when I run #hammer full-help command. But there is an exception at the end with "Error: undefined method `[]' for nil:NilClass" @Oleh which debug logs you want to get?
Sorry for not mentioning: you can observe hammer's debug output if you run any command with -d option: > hammer -d full-help And since there is an error for full-help command the debug output could help find a place where it fails. My assumption is that API docs aren't complete. This can happen if there is a plugin for hammer without corresponding plugin for Foreman. If we find why full-help fails, we probably could fix the completion as well.
I have gathered full output. I am attaching full output and it shows some ERRORS like below: ``` [DEBUG 2021-11-08T09:22:26 Exception] Using exception handler HammerCLI::ExceptionHandler#handle_general_exception [ERROR 2021-11-08T09:22:26 Exception] Error: undefined method `[]' for nil:NilClass Error: undefined method `[]' for nil:NilClass [ERROR 2021-11-08T09:22:26 Exception] NoMethodError (undefined method `[]' for nil:NilClass): /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-2.3.1/lib/hammer_cli_foreman/commands.rb:297:in `help' /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-2.3.0/lib/hammer_cli/full_help.rb:26:in `print_help' /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-2.3.0/lib/hammer_cli/full_help.rb:32:in `block in print_help' /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-2.3.0/lib/hammer_cli/full_help.rb:28:in `each' /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-2.3.0/lib/hammer_cli/full_help.rb:28:in `print_help' /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-2.3.0/lib/hammer_cli/full_help.rb:32:in `block in print_help' /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-2.3.0/lib/hammer_cli/full_help.rb:28:in `each' /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-2.3.0/lib/hammer_cli/full_help.rb:28:in `print_help' /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-2.3.0/lib/hammer_cli/full_help.rb:12:in `execute' /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.1.2/lib/clamp/command.rb:63:in `run' /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-2.3.0/lib/hammer_cli/abstract.rb:77:in `run' /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.1.2/lib/clamp/subcommand/execution.rb:11:in `execute' /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.1.2/lib/clamp/command.rb:63:in `run' /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-2.3.0/lib/hammer_cli/abstract.rb:77:in `run' /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.1.2/lib/clamp/command.rb:132:in `run' /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-2.3.0/bin/hammer:147:in `<top (required)>' /bin/hammer:23:in `load' /bin/hammer:23:in `<main>' ```
Created attachment 1840665 [details] full help output
Verified. Tested on Satellite 7.0.0 Snap 3.0 Steps Followed: 1. hammer [tab] [tab] 2. hammer-complete Observation: hammer tab completion is working fine Observing new error for hammer -d full-help report command is deprecated and will be removed in one of the future versions. Please use config-report command instead. Error: uninitialized constant HammerCLIForeman::CommandExtensions::PuppetEnvironment Since it is not related to this BZ, hence verifying it
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory (Moderate: Satellite 6.11 Release), and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. https://access.redhat.com/errata/RHSA-2022:5498