Skip to content

Drop psych dependency#1725

Open
hsbt wants to merge 4 commits into
masterfrom
drop-psych-dependency
Open

Drop psych dependency#1725
hsbt wants to merge 4 commits into
masterfrom
drop-psych-dependency

Conversation

@hsbt

@hsbt hsbt commented Jun 8, 2026

Copy link
Copy Markdown
Member

Fixes ruby/rubygems#9553

Psych is always provided Ruby 3.2+ becuase that is the default gem.

And, YAML is now Psych only. We should use Gem::YAMLSerializer instead of that when psych is not available.

hsbt and others added 2 commits June 8, 2026 15:06
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>
@matzbot

matzbot commented Jun 8, 2026

Copy link
Copy Markdown
Collaborator

🚀 Preview deployment available at: https://0fdb9777.rdoc-6cd.pages.dev (commit: 1748df3)

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 psych dependency from rdoc.gemspec.
  • Update .rdoc_options dump/load logic to use a fallback serializer when Psych isn’t available.
  • Rework RDoc.load_yaml to prefer Psych and otherwise load rubygems/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 thread lib/rdoc.rb
Comment on lines 120 to 122
begin
require 'psych'
rescue ::LoadError
Comment thread lib/rdoc/options.rb Outdated
Comment thread lib/rdoc/options.rb Outdated
Co-authored-by: Sutou Kouhei <kou@clear-code.com>
Copilot AI review requested due to automatic review settings June 8, 2026 08:29
Co-authored-by: Sutou Kouhei <kou@clear-code.com>
@hsbt

hsbt commented Jun 8, 2026

Copy link
Copy Markdown
Member Author

@kou Thanks for your review 🙏

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

Comment thread lib/rdoc/options.rb
Comment on lines +603 to +607
if yaml.respond_to?(:to_yaml)
yaml.to_yaml
else
RDoc.yaml_serializer.dump(yaml)
end
Comment thread lib/rdoc/options.rb
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 thread lib/rdoc.rb
Comment on lines 120 to 122
begin
require 'psych'
rescue ::LoadError
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 this pull request may close these issues.

WARN: Unresolved or ambiguous specs during Gem::Specification.reset:

4 participants