summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHiroshi SHIBATA <hsbt@ruby-lang.org>2026-05-01 12:04:49 +0900
committergit <svn-admin@ruby-lang.org>2026-05-07 09:24:51 +0000
commit77c7e15a67ae4eff724158b7faf841af0f4a56c2 (patch)
treebc982e9a77f4ed5ba049751e5d8213329af5cd65
parent7a111bebbb0f5d5a45d89dd77bc9e01ff55fe5dc (diff)
[ruby/rubygems] Reject `override :all, version:` in Bundler::Dsl
Version requirements are per-gem and have no meaning relative to the `:all` target. Raise ArgumentError at the DSL entry point and store nothing when this combination is given, even if other valid fields are mixed in the same call. https://github.com/ruby/rubygems/commit/aabf71f46f Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
-rw-r--r--lib/bundler/dsl.rb4
-rw-r--r--spec/bundler/bundler/dsl_spec.rb19
2 files changed, 23 insertions, 0 deletions
diff --git a/lib/bundler/dsl.rb b/lib/bundler/dsl.rb
index a5df3235b1..7a4fc3909e 100644
--- a/lib/bundler/dsl.rb
+++ b/lib/bundler/dsl.rb
@@ -186,6 +186,10 @@ module Bundler
end
def override(target, **operations)
+ if target == :all && operations.key?(:version)
+ raise ArgumentError, "`override :all, version:` is not allowed; version requirements are per-gem"
+ end
+
operations.each do |field, operation|
@overrides << Override.new(target, field, operation)
end
diff --git a/spec/bundler/bundler/dsl_spec.rb b/spec/bundler/bundler/dsl_spec.rb
index b0aa0fa05d..d5e5f830ce 100644
--- a/spec/bundler/bundler/dsl_spec.rb
+++ b/spec/bundler/bundler/dsl_spec.rb
@@ -397,5 +397,24 @@ RSpec.describe Bundler::Dsl do
it "is empty by default" do
expect(subject.overrides).to eq([])
end
+
+ it "raises ArgumentError when target is :all and version: is given" do
+ expect do
+ subject.override(:all, version: ">= 8.0")
+ end.to raise_error(ArgumentError, /`override :all, version:` is not allowed/)
+ end
+
+ it "rejects :all + version: even when other fields are also given" do
+ expect do
+ subject.override(:all, required_ruby_version: :ignore_upper, version: ">= 8.0")
+ end.to raise_error(ArgumentError, /`override :all, version:` is not allowed/)
+ end
+
+ it "does not record any override when :all + version: is rejected" do
+ expect do
+ subject.override(:all, version: ">= 8.0")
+ end.to raise_error(ArgumentError)
+ expect(subject.overrides).to eq([])
+ end
end
end