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

Psych gem compatibility issues #1684

Closed
chytreg opened this issue Feb 7, 2023 · 0 comments · Fixed by #1685
Closed

Psych gem compatibility issues #1684

chytreg opened this issue Feb 7, 2023 · 0 comments · Fixed by #1685

Comments

@chytreg
Copy link
Contributor

chytreg commented Feb 7, 2023

In my current project I'm using https://github.com/ruby/psych gem
After the upgrade from version 3.x to 4 or 5 I'm seeing this issue when running rake neo4j:schema:load"

ArgumentError: wrong number of arguments (given 2, expected 1)
/Users/chytreg/.asdf/installs/ruby/3.2.0/lib/ruby/gems/3.2.0/gems/psych-5.0.2/lib/psych.rb:322:in `safe_load'
/Users/chytreg/.asdf/installs/ruby/3.2.0/lib/ruby/gems/3.2.0/gems/activegraph-11.2.0/lib/active_graph/tasks/migration.rake:86:in `block (3 levels) in <top (required)>'
/Users/chytreg/.asdf/installs/ruby/3.2.0/lib/ruby/gems/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:279:in `block in execute'
/Users/chytreg/.asdf/installs/ruby/3.2.0/lib/ruby/gems/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:279:in `each'
/Users/chytreg/.asdf/installs/ruby/3.2.0/lib/ruby/gems/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:279:in `execute'
/Users/chytreg/.asdf/installs/ruby/3.2.0/lib/ruby/gems/3.2.0/gems/sentry-ruby-5.8.0/lib/sentry/rake.rb:26:in `execute'
/Users/chytreg/.asdf/installs/ruby/3.2.0/lib/ruby/gems/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:219:in `block in invoke_with_call_chain'
/Users/chytreg/.asdf/installs/ruby/3.2.0/lib/ruby/gems/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `synchronize'
/Users/chytreg/.asdf/installs/ruby/3.2.0/lib/ruby/gems/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `invoke_with_call_chain'
/Users/chytreg/.asdf/installs/ruby/3.2.0/lib/ruby/gems/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:188:in `invoke'

The psych gem from version 4 introduced a braking change https://github.com/ruby/psych/releases/tag/v4.0.0

# https://github.com/neo4jrb/activegraph/blob/master/lib/active_graph/tasks/migration.rake#L86
schema_data = YAML.safe_load(File.read(SCHEMA_YAML_PATH), [Symbol])
# my quick fix which works
schema_data = YAML.safe_load(File.read(SCHEMA_YAML_PATH), permitted_classes: [Symbol])

I could even open a PR, but I see that activegraph don't even specify psych as dependency, maybe it should, then we could have a clean one line fix

Runtime information:

activegraph gem version 11.2.0
psych gem version >= 4.0.0

chytreg added a commit to chytreg/activegraph that referenced this issue Feb 7, 2023
From version 4 psych, has changed the API for load_safe.

Resolves neo4jrb#1684
klobuczek pushed a commit that referenced this issue Feb 10, 2023
* Add psych as dependency and fix schema load on psych >= 4.0.1

From version 4 psych, has changed the API for load_safe.

Resolves #1684

* Ensure we use proper syntax of safe_load based on the psych version

Since ruby 1.9.2 psych is a part of ruby MRI.
From ruby 3.1.0 it comes with psych 4.0.1, which introduced a braking change into safe_load method. Ruby 3.2.0 comes with psych 5.0.1

refs:
- https://www.ruby-lang.org/en/news/2021/12/25/ruby-3-1-0-released/
- https://www.ruby-lang.org/en/news/2022/12/25/ruby-3-2-0-released/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant