Drop psych dependency#1725
Open
hsbt wants to merge 4 commits into
Open
Conversation
psych is a default gem with multiple versions installed, so declaring `psych (>= 4.0.0)` makes Gem::Specification.reset report it as an unresolved/ambiguous spec under recent Bundler and RubyGems. YAML is only used for the optional .rdoc_options file, which does not warrant a hard dependency. ruby/rubygems#9553 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Requiring yaml as a fallback when psych is missing is pointless because yaml merely loads psych anyway. When psych is genuinely unavailable, use the stub serializer shipped with RubyGems, or Bundler's copy on RubyGems older than 3.5 where rubygems/yaml_serializer does not exist yet. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Collaborator
|
🚀 Preview deployment available at: https://0fdb9777.rdoc-6cd.pages.dev (commit: 1748df3) |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR removes RDoc’s runtime dependency on the psych gem and updates .rdoc_options serialization/loading to work even when Psych is unavailable by falling back to RubyGems/Bundler’s minimal YAML serializer.
Changes:
- Remove the
psychdependency fromrdoc.gemspec. - Update
.rdoc_optionsdump/load logic to use a fallback serializer whenPsychisn’t available. - Rework
RDoc.load_yamlto prefer Psych and otherwise loadrubygems/yaml_serializer(or Bundler’s equivalent).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| rdoc.gemspec | Drops the explicit runtime dependency on psych. |
| lib/rdoc/options.rb | Switches .rdoc_options dump/load to use RDoc.yaml_serializer when Psych is missing. |
| lib/rdoc.rb | Updates YAML backend loading to prefer Psych and fall back to RubyGems/Bundler YAML serializer. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
120
to
122
| begin | ||
| require 'psych' | ||
| rescue ::LoadError |
kou
approved these changes
Jun 8, 2026
Co-authored-by: Sutou Kouhei <kou@clear-code.com>
Co-authored-by: Sutou Kouhei <kou@clear-code.com>
Member
Author
|
@kou Thanks for your review 🙏 |
Comment on lines
+603
to
+607
| if yaml.respond_to?(:to_yaml) | ||
| yaml.to_yaml | ||
| else | ||
| RDoc.yaml_serializer.dump(yaml) | ||
| end |
| options = YAML.safe_load File.read('.rdoc_options'), permitted_classes: [RDoc::Options, Symbol] | ||
| rescue Psych::SyntaxError | ||
| raise RDoc::Error, "#{options_file} is not a valid rdoc options file" | ||
| content = File.read('.rdoc_options') |
Comment on lines
120
to
122
| begin | ||
| require 'psych' | ||
| rescue ::LoadError |
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.
Fixes ruby/rubygems#9553
Psych is always provided Ruby 3.2+ becuase that is the default gem.
And,
YAMLis nowPsychonly. We should useGem::YAMLSerializerinstead of that whenpsychis not available.