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

YAML.safe_load fails with Ruby 3.1 #83

Closed
yysaki opened this issue Apr 27, 2022 · 0 comments · Fixed by #84
Closed

YAML.safe_load fails with Ruby 3.1 #83

yysaki opened this issue Apr 27, 2022 · 0 comments · Fixed by #84

Comments

@yysaki
Copy link
Contributor

yysaki commented Apr 27, 2022

Hello.

When my repository try to upgrade ruby to 3.1, I encountered ArgumentError in convergence apply .
According to ruby/psych#533, psych 4.x included a breaking change.

setting = YAML.safe_load(ERB.new(File.read(yaml_path)).result, [], [], true)

I think to use safe_load with newer options like aliases: true fixes this error.
But, what we need to consider is that we may need to drop support for older ruby 2.5 and below which are not support this option.
(My folked repository's test work with 2.5, but ruby doc doesn't exist this options...)

I will create PR to fix this error.

Reproduction:

% ruby -v
ruby 3.1.0p0 (2021-12-25 revision fb4df44d16) [x86_64-darwin20]
% cat database.yml
adapter: mysql
database: example_database
host: 127.0.0.1
username: root
password:
% bundle exec convergence apply schema.rb -c database.yml
Calling `DidYouMean::SPELL_CHECKERS.merge!(error_name => spell_checker)' has been deprecated. Please call `DidYouMean.correct_error(error_name, spell_checker)' instead.
Calling `DidYouMean::SPELL_CHECKERS.merge!(error_name => spell_checker)' has been deprecated. Please call `DidYouMean.correct_error(error_name, spell_checker)' instead.
bundler: failed to load command: convergence (/Users/yysaki/.anyenv/envs/rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/bin/convergence)
ArgumentError: wrong number of arguments (given 4, expected 1)
  /Users/yysaki/.anyenv/envs/rbenv/versions/3.1.0/lib/ruby/3.1.0/psych.rb:323:in `safe_load'
  /Users/yysaki/ghq/github.com/yysaki/convergence/lib/convergence/config.rb:48:in `load'
  /Users/yysaki/ghq/github.com/yysaki/convergence/lib/convergence/cli.rb:58:in `config'
  /Users/yysaki/ghq/github.com/yysaki/convergence/lib/convergence/cli.rb:29:in `apply'
  /Users/yysaki/.anyenv/envs/rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/thor-1.0.1/lib/thor/command.rb:27:in `run'
  /Users/yysaki/.anyenv/envs/rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/thor-1.0.1/lib/thor/invocation.rb:127:in `invoke_command'
  /Users/yysaki/.anyenv/envs/rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/thor-1.0.1/lib/thor.rb:392:in `dispatch'
  /Users/yysaki/.anyenv/envs/rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/thor-1.0.1/lib/thor/base.rb:485:in `start'
  /Users/yysaki/ghq/github.com/yysaki/convergence/bin/convergence:6:in `<top (required)>'
  /Users/yysaki/.anyenv/envs/rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/bin/convergence:25:in `load'
  /Users/yysaki/.anyenv/envs/rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/bin/convergence:25:in `<top (required)>'

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

Successfully merging a pull request may close this issue.

1 participant