0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

bundle install で WARN: Unresolved or ambiguous specs during Gem::Specification.reset が出る

0
Posted at

bundle installbundle update したら

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

といった警告が出ることがある。
これについて調べた(未解決)。

環境

% ruby -v
ruby 3.4.8 (2025-12-17 revision 995b59f666) +PRISM [arm64-darwin25]
% gem -v 
4.0.7
% bundle -v
4.0.7
% gem list psych

*** LOCAL GEMS ***

psych (5.3.1, default: 5.2.2)

全て記事執筆時点の最新の状態である。

再現手順

空のディレクトリーで

bundle init

する。
Gemfile のひな形が出来る。

Gemfile に何か一つ gem を記載する。

Gemfile
# frozen_string_literal: true

source "https://rubygems.org"

gem "date"

ここでは標準添付ライブラリーの date gem を書いてみたが,添付ライブラリーではない zeitwerk とか rubyzip とかでもいい。

bundle install する:

% bundle install
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.3.1
      - 5.2.2
WARN: Clearing out unresolved specs. Try 'gem cleanup <gem>'
Please report a bug if this causes problems.
Bundle complete! 1 Gemfile dependency, 1 gem now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.

成功しているのだが,psych のバージョンに関して何か警告が出ている。

psych は Gemfile に記載した gem とは関係ない(依存 gem でもない)のだが,なぜこんな警告が出るのか。

他の Bundler コマンドでは

bundle check では警告は出ないようだ。

bundle update では出る。
(今の Bundler では bundle update--all オプションを付けないと別の警告も出るが,本題と関係ないので本記事では略す)

Gemfile.lock が存在している状態での bundle install では警告は出ない。

psych を整理したら

警告メッセージには

psych (>= 4.0.0)
Available/installed versions of this gem:
- 5.3.1
- 5.2.2

とあり,

Try 'gem cleanup '

とある。
しかし,インストールされている psych のうち古いほう(5.2.2)は default gem なので,

gem cleanup psych

とやったところで何も起こらない。

では新しいほうを削除したどうなるか。
→警告は出なくなった。

Gemfile に psych を入れたら

psych は使ってないのだが,バージョンが曖昧だとか言っているので,Gemfile に gem "psych" を入れてみたどうだろう。

まず,バージョン指定なしで:

Gemfile(抜粋)
gem "psych"

→警告は出る。

では,新しいほうをあらわに指定:

Gemfile(抜粋)
gem "psych", "5.3.1"

→警告は出る。

古いほうをあらわに指定:

Gemfile(抜粋)
gem "psych", "5.2.2"

→やはり警告は出る。
しかも,default gem の 5.2.2 があるにもかかわらず,bundle installbundle update で 5.2.2 がもう一つインストールされるというワケの分からないことが起こる。

issue は?

このへんが類似の問題を扱っているが,読んでもよく分からない。

https://github.com/ruby/rubygems/issues/7657
https://github.com/ruby/rubygems/issues/2886

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?