ITADN

False ambiguous specs warning for default Psych when activating RDoc

#9600Opendorianmariecom 创建于 2026-06-05
D
dorianmariecomcommented
### Describe the problem as clearly as you can RubyGems emits an `Unresolved or ambiguous specs during Gem::Specification.reset` warning for `psych (>= 4.0.0)` after activating `rdoc` when both Ruby's default Psych gem and a newer installed Psych gem are visible. The warning suggests `gem cleanup <gem>`, but that does not fully help when one matching Psych spec is the default gem that ships with Ruby. The same warning showed up for me during `bundle update --all` in a Rails app after Bundler updated `psych` from `5.3.1` to `5.4.0` while Ruby 3.4.5 still provides default `psych 5.2.2`. I did not find an existing issue with the warning text plus the Psych/RDoc combination. ### Did you try upgrading rubygems & bundler? Yes. The warning happened with RubyGems 3.6.9 and Bundler 4.0.3. I also reproduced it during `bundle _4.0.13_ update --all` before reducing it to RubyGems/RDoc/Psych. ### Post steps to reproduce the problem On Ruby 3.4.5, with default Psych still present, install a newer Psych and activate RDoc: ```sh tmp_gem_home=$(mktemp -d) export GEM_HOME="$tmp_gem_home" export GEM_PATH="$tmp_gem_home:$(ruby -rrubygems -e 'print Gem.default_dir')" gem install psych -v 5.4.0 --no-document ruby -rrubygems -e 'puts RUBY_DESCRIPTION; puts "RubyGems #{Gem::VERSION}"; puts Gem::Specification.find_all_by_name("psych").map { |s| "psych #{s.version} default=#{s.default_gem?}" }; gem "rdoc"; p Gem::Specification.unresolved_deps; Gem::Specification.reset' ``` In my app, the original command that surfaced it was simply: ```sh bundle update --all ``` ### Which command did you run? Minimal repro: ```sh ruby -rrubygems -e 'gem "rdoc"; Gem::Specification.reset' ``` Original command: ```sh bundle update --all ``` ### What were you expecting to happen? I expected `Gem::Specification.reset` not to warn in this situation, or at least not to suggest `gem cleanup` when the ambiguity involves a default gem that cannot be cleaned away normally. RubyGems appears to intentionally suppress this class of warning for `latest_version?` dependencies when a default gem is present: ```ruby next if dep.latest_version? && matching_versions.any?(&:default_gem?) ``` But RDoc declares `psych (>= 4.0.0)`, so that suppression does not apply even though this seems like the same default-gem ambiguity. ### What actually happened? With Ruby 3.4.5 and RubyGems 3.6.9: ```text ruby 3.4.5 (2025-07-16 revision 20cda200d3) +PRISM [arm64-darwin24] RubyGems 3.6.9 psych 5.4.0 default=false psych 5.2.2 default=true {"psych" => <Gem::Dependency type=:runtime name="psych" requirements=">= 4.0.0">, "erb" => <Gem::Dependency type=:runtime name="erb" requirements=">= 0">} WARN: Unresolved or ambiguous specs during Gem::Specification.reset: psych (>= 4.0.0) Available/installed versions of this gem: - 5.4.0 - 5.2.2 WARN: Clearing out unresolved specs. Try 'gem cleanup <gem>' Please report a bug if this causes problems. ``` The original Bundler output was: ```text Fetching gem metadata from https://rubygems.org/.......... Resolving dependencies... WARN: Unresolved or ambiguous specs during Gem::Specification.reset: psych (>= 4.0.0) Available/installed versions of this gem: - 5.4.0 - 5.2.2 WARN: Clearing out unresolved specs. Try 'gem cleanup <gem>' Please report a bug if this causes problems. Bundle updated! ``` ### Workarounds found Both of these avoided the warning locally: ```sh RUBYOPT=-rpsych bundle update --all ``` or pinning Psych to Ruby 3.4.5's default version and removing the newer installed copy: ```ruby gem "psych", "5.2.2" ``` ### Environment ```text ruby 3.4.5 (2025-07-16 revision 20cda200d3) +PRISM [arm64-darwin24] RubyGems 3.6.9 Bundler 4.0.3; also observed with Bundler 4.0.13 macOS arm64-darwin24 ```
2 条评论