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

Đang mở Phù hợp với người mới
#10,017 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@smasry đang làm issue này rồi.

Từ ngày 6/11/2026.

  • #10030 của @smasry — đang mở

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
73/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
ruby
Lĩnh vực
backend, cli

Hướng nghiên cứu

Lỗi nằm trong Bundler::Settings#load_config tại bundler-4.0.23/lib/bundler/settings.rb:485; hãy đọc phương thức đó và so sánh cách xử lý được thêm trong commit 368fc29ce1. Tái hiện lỗi bằng nội dung .bundle/config được cung cấp và bundle _4.0.23_ config list trên Ruby 4.1. Công việc hoàn tất khi lệnh đọc cấu hình YAML trống mà không phát sinh ngoại lệ và trường hợp đó được kiểm thử.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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)
Ngôn ngữ chính
Ruby
Star
4k
Fork
2k
Merge trung bình
1 ngày 17 giờ
Pull request đã merge (30 ngày)
50

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của ruby/rubygems

Tất cả issue của ruby/rubygems

Issue tương tự

Thêm issue về Ruby

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.