Bundler 4.0.x fails on Ruby 4.1 when .bundle/config is "---"

オープン 初心者向け
#10,017 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@smasry がすでに取り組んでいます。

2026年11月6日 から。

  • #10030 @smasry による — オープン

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
73/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
ruby
領域
backend, cli

調査の方向性

失敗箇所は Bundler::Settings#load_config の bundler-4.0.23/lib/bundler/settings.rb:485 です。このメソッドを読み、コミット 368fc29ce1 で追加された処理と比較してください。提供された .bundle/config の内容と bundle _4.0.23_ config list を使い、Ruby 4.1 で再現してください。コマンドが空の YAML 設定を例外を発生させずに読み込み、そのケースがテストでカバーされれば完了です。

索引モデルが issue の本文から書いたものです。

説明

Describe the problem as clearly as you can

On Ruby 4.1.0dev (RubyGems 4.1.0.beta3), every Bundler 4.0.x command fails when .bundle/config contains only ---:

bundler-4.0.23/lib/bundler/settings.rb:485:in 'block in Bundler::Settings#load_config': undefined method 'inject' for nil (NoMethodError)

Bundler writes this file itself. bundle config unset on the last local key leaves ---\n behind, and the global config does the same. On Ruby 4.1 an app with BUNDLED WITH 4.0.x runs that Bundler, so the app stops working until someone deletes the file.

#9379 made Gem::YAMLSerializer.load("---\n") return nil (c091444047). The same PR made Bundler treat nil as {} (368fc29ce1). Bundler 4.0.x uses Gem::YAMLSerializer when RubyGems provides it, but 368fc29ce1 is not on the 4.0 branch. #9379 has no labels, so I think prepare_release would not pick it up.

Could 368fc29ce1 go into the next 4.0.x release? It cherry-picks cleanly onto 4.0 (642a23eb5), and with it Bundler reads the file on Ruby 4.0.7 and 4.1.0dev.

Did you try upgrading rubygems & bundler?

Yes. It reproduces with Bundler 4.0.20 and 4.0.23, the latest 4.0.x. Bundler 4.1.0.beta3 works.

Post steps to reproduce the problem
ruby -e 'require "rubygems/yaml_serializer"; p Gem::YAMLSerializer.load("---\n")'  # 4.0.7: {}  4.1.0dev: nil
mkdir .bundle && printf -- '---\n' > .bundle/config && bundle _4.0.23_ config list

Ruby 4.1.0dev (2026-11-02T20:50:33Z HEAD b51db981f6) on Linux x86_64.

Which command did you run?

bundle _4.0.23_ config list. bundle install fails the same way.

What were you expecting to happen?

The settings list, as on Ruby 4.0.7.

What happened instead?
undefined method 'inject' for nil (NoMethodError)
主要言語
Ruby
スター
4k
フォーク
2k
平均マージ
1日 17時間
マージ済み PR(30日)
50

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

ruby/rubygems のほかの issue

ruby/rubygems の issue をすべて見る

似ている issue

Ruby の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。