You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

为何`gem cleanup`会报告默认psych gem存在多个模糊引用?

Ruby 3.4.x 执行 gem cleanup psych 出现模糊规格警告的问题排查

问题描述

在多个macOS版本(包括Sequoia)以及Ruby 3.4.x(具体为3.4.4和3.4.5)环境中,执行gem cleanup psych时会出现以下警告:

$ gem cleanup --debug --backtrace psych
NOTE:  Debugging mode prints all exceptions even when rescued
Cleaning up installed gems...
WARN: Unresolved or ambiguous specs during Gem::Specification.reset:
      psych (>= 4.0.0)
      Available/installed versions of this gem:
      - 5.1.2
      - 5.1.2
WARN: Clearing out unresolved specs. Try 'gem cleanup <gem>'
Please report a bug if this causes problems.
Clean up complete

Psych 5.1.2是默认gem,尝试过执行gem pristine psych,但结果相同。目前无法确定依赖链中哪个已安装或默认gem导致了“未解析或模糊规格”的问题。该警告仅在执行gem clean时出现,未对CRuby 3.3.5造成功能性影响。

依赖检查与调试

为排查问题,执行了以下命令:

$ gem dependency psych
Gem psych-5.1.2
  stringio (>= 0)

Gem psych-5.1.2
  stringio (>= 0)

该结果未提供有效排查信息。但检查psych的反向依赖时发现:

$ gem dependency -R psych
Gem psych-5.1.2
  stringio (>= 0)
  Used by
    rdoc-6.7.0 (psych (>= 4.0.0))
    rdoc-6.6.3.1 (psych (>= 4.0.0))

Gem psych-5.1.2
  stringio (>= 0)
  Used by
    rdoc-6.7.0 (psych (>= 4.0.0))
    rdoc-6.6.3.1 (psych (>= 4.0.0))

这似乎是问题根源,因为gem list rdoc返回:

rdoc (6.7.0, default: 6.6.3.1)

但rdoc 6.6.3.1是默认gem,无法卸载。尝试了以下操作:

$ gem uninstall -v 6.6.3.1 --force rdoc
Gem rdoc-6.6.3.1 cannot be uninstalled because it is a default gem

$ gem pristine -v 6.6.3.1  rdoc
Restoring gems to pristine condition...
Skipped rdoc-6.6.3.1, it is a default gem

同类案例查找

目前不清楚如何进一步调试或解决这个“模糊规格”错误。谷歌搜索未找到有效结果,在Stack Overflow上搜索[ruby] Gem::Specification.reset psych也未找到匹配场景的案例。

内容的提问来源于stack exchange,提问作者Todd A. Jacobs

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.17 23:32:05