Use JSON.parse instead of Gem::SafeYAML for cargo metadata#714
Merged
gjtorikian merged 1 commit intooxidize-rb:mainfrom Mar 12, 2026
Merged
Use JSON.parse instead of Gem::SafeYAML for cargo metadata#714gjtorikian merged 1 commit intooxidize-rb:mainfrom
gjtorikian merged 1 commit intooxidize-rb:mainfrom
Conversation
4 tasks
|
|
gjtorikian
reviewed
Mar 12, 2026
`cargo metadata --format-version 1` output is JSON. Parsing it with Gem::SafeYAML.safe_load worked incidentally because JSON is valid YAML when parsed by Psych, but Ruby 4.1.0dev sets Gem.use_psych? to false, causing SafeYAML to fall through to Gem::YAMLSerializer which cannot parse JSON correctly.
ea7ff56 to
cd3078a
Compare
Member
|
thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
cargo metadata --format-version 1output is JSON. Parsing it with Gem::SafeYAML.safe_load worked incidentally because JSON is valid YAML when parsed by Psych, but Ruby 4.1.0dev (as of ruby/ruby@2c9e4befbf01) sets Gem.use_psych? to false, causing SafeYAML to fall through to Gem::YAMLSerializer which returns a string instead of a hash and rb-sys raises.The
test_cargo_metadata.rbtest fails on ruby-head but passes with this change.refs ruby/rubygems#9352