Hammer cli 3.1.0 ruby error : string.rb:70:in `%': named{file} after unnumbered(1) (ArgumentError)

Problem:

I have a problem with hammer cli 3.1.0 , everytime i try to run the “hammer” command it display the error message bellow :

I have tried to uninstall and reinstall the hammer_cli packages, but it show me the same error.

Please help !

Thanks

Expected outcome:

[root@yam ~]# hammer
Traceback (most recent call last):
    13: from /bin/hammer:23:in `<main>'
    12: from /bin/hammer:23:in `load'
    11: from /usr/share/gems/gems/hammer_cli-3.1.0/bin/hammer:124:in `<top (required)>'
    10: from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:83:in `require'
     9: from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:83:in `require'
     8: from /usr/share/gems/gems/hammer_cli-3.1.0/lib/hammer_cli.rb:16:in `<top (required)>'
     7: from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:83:in `require'
     6: from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:83:in `require'
     5: from /usr/share/gems/gems/hammer_cli-3.1.0/lib/hammer_cli/abstract.rb:9:in `<top (required)>'
     4: from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:83:in `require'
     3: from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:83:in `require'
     2: from /usr/share/gems/gems/hammer_cli-3.1.0/lib/hammer_cli/clamp.rb:8:in `<top (required)>'
     1: from /usr/share/gems/gems/fast_gettext-1.4.1/lib/fast_gettext/vendor/string.rb:70:in `%'
/usr/share/gems/gems/fast_gettext-1.4.1/lib/fast_gettext/vendor/string.rb:70:in `%': named{file} after unnumbered(1) (ArgumentError)

Foreman and Proxy versions:

Foreman 3.1.0

Foreman and Proxy plugin versions:

katello 4.3.0
rubygem-hammer_cli*-3.1.0

Distribution and version:

AlmaLinux 8.5

Other relevant data:

Hi @siriwliw, @Zippopotamme,

I’m so sorry for not responding earlier. I see that you both encounter the same error. Could one of you (or both) please provide -d full output when you see this error? I’ve tried my best to reproduce it, but without any luck.

1 Like

Hi @ofedoren ,

Thanks for your reply.

Here is the full output with -d option :

[root@yam ~]# hammer -d
[ INFO 2022-01-10T11:41:51 Init] Initialization of Hammer CLI (3.1.0) has started...
[DEBUG 2022-01-10T11:41:51 Init] Running at ruby 2.7.4-p191
[ INFO 2022-01-10T11:41:51 Init] Configuration from the file /etc/hammer/cli_config.yml has been loaded
[ INFO 2022-01-10T11:41:51 Init] Configuration from the file /etc/hammer/cli.modules.d/foreman.yml has been loaded
[ INFO 2022-01-10T11:41:51 Init] Configuration from the file /etc/hammer/cli.modules.d/foreman_puppet.yml has been loaded
[ INFO 2022-01-10T11:41:51 Init] Configuration from the file /etc/hammer/cli.modules.d/foreman_remote_execution.yml has been loaded
[ INFO 2022-01-10T11:41:51 Init] Configuration from the file /etc/hammer/cli.modules.d/foreman_tasks.yml has been loaded
[ INFO 2022-01-10T11:41:51 Init] Configuration from the file /etc/hammer/cli.modules.d/katello.yml has been loaded
[ INFO 2022-01-10T11:41:51 Init] Configuration from the file /root/.hammer/defaults.yml has been loaded
[ INFO 2022-01-10T11:41:51 Init] Configuration from the file /root/.hammer/cli.modules.d/foreman.yml has been loaded
Traceback (most recent call last):
        13: from /bin/hammer:23:in `<main>'
        12: from /bin/hammer:23:in `load'
        11: from /usr/share/gems/gems/hammer_cli-3.1.0/bin/hammer:124:in `<top (required)>'
        10: from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:83:in `require'
         9: from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:83:in `require'
         8: from /usr/share/gems/gems/hammer_cli-3.1.0/lib/hammer_cli.rb:16:in `<top (required)>'
         7: from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:83:in `require'
         6: from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:83:in `require'
         5: from /usr/share/gems/gems/hammer_cli-3.1.0/lib/hammer_cli/abstract.rb:9:in `<top (required)>'
         4: from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:83:in `require'
         3: from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:83:in `require'
         2: from /usr/share/gems/gems/hammer_cli-3.1.0/lib/hammer_cli/clamp.rb:8:in `<top (required)>'
         1: from /usr/share/gems/gems/fast_gettext-1.4.1/lib/fast_gettext/vendor/string.rb:70:in `%'
/usr/share/gems/gems/fast_gettext-1.4.1/lib/fast_gettext/vendor/string.rb:70:in `%': named{file} after unnumbered(1) (ArgumentError)

Bonjour,

I have the same problem after upgraded to 3.0.1

hammer 2.3.1 installed on my desktop still works with my 3.0.1 server

Regards,

Frederic

Thank you all for reporting this. Although, the debug output didn’t tell much… I have this on my prio list.

Well, guys, I’m kinda desperate here trying to reproduce this error.

What I’ve tried:

  • Latest devel version + local checkouts of both Foreman and hammer [OK]
  • Install hammer as RPM packages in SCL mode [OK]
  • Install fresh Foreman 3.0+ [OK]
  • Install fresh Foreman 2.5 and upgrade it to Foreman 3.0 [OK]
  • Install fresh Foreman 3.0 + Katello [OK]
  • Install fresh Foreman 2.5 + Katello and upgrade it to Foreman 3.0 + Katello [OK]

Plugins included:

  • None [OK]
  • hammer (3.0.1) [OK]
    • hammer_cli_foreman (3.0.0)
    • hammer_cli_foreman_puppet (0.0.3)
    • hammer_cli_foreman_remote_execution (unknown version)
    • hammer_cli_foreman_tasks (unknown version)
    • hammer_cli_katello (1.1.2)

OS I was testing on:

  • CentOS 7 [OK]

Ruby version:

  • 2.7.1-p83 [OK]
  • 2.7.4-p191 [OK]

Fast-gettext version:

  • Latest [OK]
  • 1.4.1 [OK]
  • Actually, there are no differences between two in terms of changes in fast_gettext-1.4.1/lib/fast_gettext/vendor/string.rb

My question now is: what do you guys have in common? A different OS, maybe other language settings for OS/hammer, different installation (gem install vs yum)?

Unfortunatelly, the error all of you encountered gives me nothing in terms of where to look at, since nothing changed in fast_gettext library or in hammer where the error gets raised. My assumption was that there is something related to the extracted string for localization, some magic around interpolation, but it seems like nothing changed. And even if it was, I used the same versions of Ruby/libraries/hammer, so I would face the same error. I thought that it might be even due to Puppet extraction in hammer (which happened between 2.5 and 3.0 releases), but it was tested quite a few times and we didn’t encountered thing like that. Hammer gets properly loaded with/without Puppet as well.

So, now I’m asking for your help to understand what we have/do differently.

I can not see any difference execpt ruby version

tfm-rubygem-hammer_cli-3.0.1-1.el7.noarch
tfm-rubygem-hammer_cli_foreman_tasks-0.0.16-1.fm3_0.el7.noarch
tfm-rubygem-hammer_cli_foreman_puppet-0.0.3-1.fm3_0.el7.noarch
tfm-rubygem-hammer_cli_foreman-3.0.0-1.el7.noarch
tfm-rubygem-hammer_cli_foreman_remote_execution-0.2.2-1.fm3_0.el7.noarch
tfm-rubygem-hammer_cli_foreman-doc-3.0.0-1.el7.noarch

tfm-rubygem-fast_gettext-1.4.1-5.el7.noarch

rh-ruby27-ruby-2.7.4-130.el7.x86_64 from centos-sclo-rh

Thank you

Regards,

Frederic

I made a fresh (foreman-release and tfm-rubygem-hammer_cli_foreman)

hammer 2.5 is working and not 3.0 or 3.1

I check the differences in the packages between 2.5 and 3.0 and I get

tfm-rubygem-hammer_cli_foreman.noarch_0:2.5.1-1.el7
tfm-rubygem-hammer_cli_foreman.noarch_0:3.0.0-1.el7

tfm-rubygem-hammer_cli.noarch_0:3.0.1-1.el7
tfm-rubygem-hammer_cli.noarch_0:2.5.1-1.el7

tfm-runtime.x86_64_0:7.0-2.el7
tfm-runtime.x86_64_0:7.0-4.el7

I start a new 2.5 hammer_cli_foreman then upgrade foreman-release to 3.0

after upgrading just tfm-runtime, hammer still works

but when I do the same and upgrade just tfm-rubygem-hammer_cli, I got the error

I also tried just to upgrade tfm-rubygem-hammer_cli_foreman but hammer crash

I will try to check the differences between tfm-rubygem-hammer_cli packages

All, the fix is ready: Fixes #34204 - Fix FR translation by ofedoren · Pull Request #358 · theforeman/hammer-cli · GitHub. It appears that somehow one of the translated strings got broken and it seems like only for French locale :confused:

You could try to apply the patch by yourself in the meantime, but I’ll do minor releases (hammer-cli-3.0.2 and hammer-cli-3.1.1) with this fix anyway after it gets merged :slight_smile:

Thanks

The patch works. I will test the upgrades

Thank you

Hi @ofedoren ,

Can you please explain to me how can I apply this patch ? I didn’t find the new hammer 3.1.1 version in foreman repo : Index of /releases/3.1/el8/x86_64 (theforeman.org)

Thank you

Bonjour,

If you do not need translation, you can just rename the file hammer-cli.mo
in the directory /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-/locale/fr/LC_MESSAGES

otherwise you also need to download the version here : Fixes #34204 - Fix FR translation

Regards,

Frederic

1 Like

Hi @frederic ,

It works for me, thank you very much for your help.

Thanks to @ofedoren for this correction.

Regards,