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

`safe_load': wrong number of arguments (given 4, expected 1) (ArgumentError) #1143

Closed
antenore opened this issue Sep 15, 2021 · 5 comments · Fixed by #1147
Closed

`safe_load': wrong number of arguments (given 4, expected 1) (ArgumentError) #1143

antenore opened this issue Sep 15, 2021 · 5 comments · Fixed by #1147
Labels

Comments

@antenore
Copy link

I've installed pdk as a gem, because I don't have better options at the moment.

When the gem psych is installed (v4.0.1) I have the above error, that sounds to me a weird name clashing.

I think the problem is in psych, I'll report the same to them, unfortunately I cannot investigate further, at the moment I've just removed psych.

The full error:

$ pdk convert --noop --default-template -d
pdk (DEBUG): Detected a Puppet Module context at /puppet/modules/mail
pdk (DEBUG): Detected an unknown context at /puppet/dev/puppet/modules
Traceback (most recent call last):
        20: from /home/antenore/.rvm/gems/ruby-2.6.6/bin/ruby_executable_hooks:22:in `<main>'
        19: from /home/antenore/.rvm/gems/ruby-2.6.6/bin/ruby_executable_hooks:22:in `eval'
        18: from /home/antenore/.rvm/gems/ruby-2.6.6/bin/pdk:23:in `<main>'
        17: from /home/antenore/.rvm/gems/ruby-2.6.6/bin/pdk:23:in `load'
        16: from /home/antenore/.rvm/gems/ruby-2.6.6/gems/pdk-2.2.0/exe/pdk:6:in `<top (required)>'
        15: from /home/antenore/.rvm/gems/ruby-2.6.6/gems/pdk-2.2.0/lib/pdk/cli.rb:71:in `run'
        14: from /home/antenore/.rvm/gems/ruby-2.6.6/gems/cri-2.15.11/lib/cri/command.rb:316:in `run'
        13: from /home/antenore/.rvm/gems/ruby-2.6.6/gems/cri-2.15.11/lib/cri/command.rb:298:in `run'
        12: from /home/antenore/.rvm/gems/ruby-2.6.6/gems/cri-2.15.11/lib/cri/command.rb:362:in `run_this'
        11: from /home/antenore/.rvm/gems/ruby-2.6.6/gems/pdk-2.2.0/lib/pdk/cli/convert.rb:37:in `block (2 levels) in <module:CLI>'
        10: from /home/antenore/.rvm/gems/ruby-2.6.6/gems/pdk-2.2.0/lib/pdk/cli/util.rb:300:in `analytics_screen_view'
         9: from /home/antenore/.rvm/gems/ruby-2.6.6/gems/pdk-2.2.0/lib/pdk.rb:67:in `analytics'
         8: from /home/antenore/.rvm/gems/ruby-2.6.6/gems/pdk-2.2.0/lib/pdk/config.rb:155:in `get_within_scopes'
         7: from /home/antenore/.rvm/gems/ruby-2.6.6/gems/pdk-2.2.0/lib/pdk/config.rb:155:in `each'
         6: from /home/antenore/.rvm/gems/ruby-2.6.6/gems/pdk-2.2.0/lib/pdk/config.rb:156:in `block in get_within_scopes'
         5: from /home/antenore/.rvm/gems/ruby-2.6.6/gems/pdk-2.2.0/lib/pdk/config.rb:297:in `traverse_object'
         4: from /home/antenore/.rvm/gems/ruby-2.6.6/gems/pdk-2.2.0/lib/pdk/config.rb:291:in `traverse_object'
         3: from /home/antenore/.rvm/gems/ruby-2.6.6/gems/pdk-2.2.0/lib/pdk/config/namespace.rb:99:in `[]'
         2: from /home/antenore/.rvm/gems/ruby-2.6.6/gems/pdk-2.2.0/lib/pdk/config/namespace.rb:345:in `settings'
         1: from /home/antenore/.rvm/gems/ruby-2.6.6/gems/pdk-2.2.0/lib/pdk/config/yaml.rb:16:in `parse_file'
/home/antenore/.rvm/gems/ruby-2.6.6/gems/psych-4.0.1/lib/psych.rb:323:in `safe_load': wrong number of arguments (given 4, expected 1) (ArgumentError)
@antenore antenore added bug needs-triage Newly created issue that has not been reviewed by a PDK contributor labels Sep 15, 2021
@antenore
Copy link
Author

Back link for completeness

ruby/psych#519

@olleolleolle
Copy link
Contributor

olleolleolle commented Sep 15, 2021

https://github.com/puppetlabs/pdk/blob/main/lib/pdk/config/yaml.rb#L16 uses the "positional args" version of the method, which has been removed. This is not a defect in ruby/psych - it's a newer API.

In order for pdk to be more compatible with different YAML library versions, check which version is in use:

https://makandracards.com/makandra/465149-ruby-the-yaml-safe_load-method-hides-some-pitfalls#note-section-new-safeload-api

Hope this helps!

@sanfrancrisko sanfrancrisko removed the needs-triage Newly created issue that has not been reviewed by a PDK contributor label Oct 11, 2021
@sanfrancrisko
Copy link
Contributor

Thanks @antenore for the report and @olleolleolle for the additional info. Have been able to reproduce this on my side too.

We are currently working on the next generation of the PDK (see this blog post, which will not carry this issue over. However, we may still be performing a maintenance / bug fix release - we'll try to prioritise resolving this conflict, if we release a new version of the PDK in the near term

@binford2k
Copy link
Contributor

@antenore if you need this right now, you can correct your own install with this patch.

@antenore
Copy link
Author

@binford2k thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants