From 607648d5fc98782018a40c45079d300c48f684c4 Mon Sep 17 00:00:00 2001 From: Shinichi Maeshima Date: Wed, 29 Apr 2026 19:11:00 +0900 Subject: [PATCH 1/6] [ruby/rubygems] Make `bundle config get` return status 1 when the value is not set MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix https://github.com/ruby/rubygems/pull/3215 Change the exit status to 1 when trying to `get` a config key that does not exist, as shown below. ```sh $ bundle config get foo Settings for `foo` in order of priority. The top value will be used You have not configured a value for `foo` $ echo $? 1 ``` It seems that showing “Settings for `foo` in order of priority. The top value will be used” when the key does not exist is not very meaningful, but for now I have left the behavior unchanged except for the exit status. In the tests, some existing cases try to `get` a missing config without `raise_on_error: false`, so set the value in advance or add `raise_on_error: false` to handle them. https://github.com/ruby/rubygems/commit/73205e3d64 --- lib/bundler/cli/config.rb | 15 +++++++++++++-- spec/bundler/bundler/cli_spec.rb | 4 +++- spec/bundler/commands/config_spec.rb | 15 ++++++++++----- spec/bundler/other/major_deprecation_spec.rb | 2 +- 4 files changed, 27 insertions(+), 9 deletions(-) diff --git a/lib/bundler/cli/config.rb b/lib/bundler/cli/config.rb index 6a77e4a65ea386..3ac973cfe181c3 100644 --- a/lib/bundler/cli/config.rb +++ b/lib/bundler/cli/config.rb @@ -88,15 +88,26 @@ def run if value.nil? warn_unused_scope "Ignoring --#{scope} since no value to set was given" + configured = Bundler.settings.locations(name).any? + if options[:parseable] if value = Bundler.settings[name] Bundler.ui.info("#{name}=#{value}") end - return + if configured + return + else + exit 1 + end end confirm(name) - return + + if configured + return + else + exit 1 + end end Bundler.ui.info(message) if message diff --git a/spec/bundler/bundler/cli_spec.rb b/spec/bundler/bundler/cli_spec.rb index d1e6d7d411d77d..56caf9937e29f6 100644 --- a/spec/bundler/bundler/cli_spec.rb +++ b/spec/bundler/bundler/cli_spec.rb @@ -251,8 +251,10 @@ def out_with_macos_man_workaround context "running a parseable command" do it "prints no warning" do + bundle "config set foo value", env: { "BUNDLER_VERSION" => bundler_version } bundle "config get --parseable foo", env: { "BUNDLER_VERSION" => bundler_version } - expect(stdboth).to eq "" + expect(out).to eq "foo=value" + expect(err).to eq "" bundle "platform --ruby", env: { "BUNDLER_VERSION" => bundler_version }, raise_on_error: false expect(stdboth).to eq "Could not locate Gemfile" diff --git a/spec/bundler/commands/config_spec.rb b/spec/bundler/commands/config_spec.rb index 5cafbe346810bc..0aaae98ccbc0bd 100644 --- a/spec/bundler/commands/config_spec.rb +++ b/spec/bundler/commands/config_spec.rb @@ -313,9 +313,10 @@ describe "parseable option" do it "prints an empty string" do - bundle "config get foo --parseable" + bundle "config get foo --parseable", raise_on_error: false expect(out).to eq "" + expect(last_command).to be_failure end it "only prints the value of the config" do @@ -501,8 +502,9 @@ it "get" do ENV["BUNDLE_BAR"] = "bar_val" - bundle "config get foo" + bundle "config get foo", raise_on_error: false expect(out).to eq "Settings for `foo` in order of priority. The top value will be used\nYou have not configured a value for `foo`" + expect(last_command).to be_failure ENV["BUNDLE_FOO"] = "foo_val" @@ -547,7 +549,8 @@ bundle "config unset foo" expect(out).to eq "" - expect(bundle("config get foo")).to eq "Settings for `foo` in order of priority. The top value will be used\nYou have not configured a value for `foo`" + expect(bundle("config get foo", raise_on_error: false)).to eq "Settings for `foo` in order of priority. The top value will be used\nYou have not configured a value for `foo`" + expect(last_command).to be_failure bundle "config set --local foo 1" bundle "config set --global foo 2" @@ -557,7 +560,8 @@ expect(bundle("config get foo")).to eq "Settings for `foo` in order of priority. The top value will be used\nSet for the current user (#{home(".bundle/config")}): \"2\"" bundle "config unset foo --global" expect(out).to eq "" - expect(bundle("config get foo")).to eq "Settings for `foo` in order of priority. The top value will be used\nYou have not configured a value for `foo`" + expect(bundle("config get foo", raise_on_error: false)).to eq "Settings for `foo` in order of priority. The top value will be used\nYou have not configured a value for `foo`" + expect(last_command).to be_failure bundle "config set --local foo 1" bundle "config set --global foo 2" @@ -567,7 +571,8 @@ expect(bundle("config get foo")).to eq "Settings for `foo` in order of priority. The top value will be used\nSet for your local app (#{bundled_app(".bundle/config")}): \"1\"" bundle "config unset foo --local" expect(out).to eq "" - expect(bundle("config get foo")).to eq "Settings for `foo` in order of priority. The top value will be used\nYou have not configured a value for `foo`" + expect(bundle("config get foo", raise_on_error: false)).to eq "Settings for `foo` in order of priority. The top value will be used\nYou have not configured a value for `foo`" + expect(last_command).to be_failure bundle "config unset foo --local --global", raise_on_error: false expect(last_command).to be_failure diff --git a/spec/bundler/other/major_deprecation_spec.rb b/spec/bundler/other/major_deprecation_spec.rb index 6eeb70abe50b6f..ab7589d698d2ed 100644 --- a/spec/bundler/other/major_deprecation_spec.rb +++ b/spec/bundler/other/major_deprecation_spec.rb @@ -290,7 +290,7 @@ describe "old get interface" do before do - bundle "config waka" + bundle "config waka", raise_on_error: false end it "warns", bundler: "4" do From 842c847c79d57de4c2d9b3199679fceaab839899 Mon Sep 17 00:00:00 2001 From: Shinichi Maeshima Date: Tue, 5 May 2026 17:13:52 +0900 Subject: [PATCH 2/6] [ruby/rubygems] Simplify the code Refactor the code based on the feedback in https://github.com/ruby/rubygems/pull/9505#discussion_r3167085736 . https://github.com/ruby/rubygems/commit/153abcb5e3 --- lib/bundler/cli/config.rb | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/lib/bundler/cli/config.rb b/lib/bundler/cli/config.rb index 3ac973cfe181c3..8248e3b15b335f 100644 --- a/lib/bundler/cli/config.rb +++ b/lib/bundler/cli/config.rb @@ -87,23 +87,17 @@ def run if value.nil? warn_unused_scope "Ignoring --#{scope} since no value to set was given" - - configured = Bundler.settings.locations(name).any? + current_value = Bundler.settings[name] if options[:parseable] if value = Bundler.settings[name] Bundler.ui.info("#{name}=#{value}") end - if configured - return - else - exit 1 - end + else + confirm(name) end - confirm(name) - - if configured + if current_value return else exit 1 From c9ee9c1e23ac27cf2699a41e221e05d82f30e4c3 Mon Sep 17 00:00:00 2001 From: Shinichi Maeshima Date: Thu, 7 May 2026 19:03:03 +0900 Subject: [PATCH 3/6] [ruby/rubygems] Return exit status 1 only when the config value is nil When using something like `bundle config set foo false`, the config value is converted via `Bundler::Settings#converted_value`, so the stored value becomes `false` instead of the string `"false"`. Because of that, passing `Bundler.settings[name]` directly to an `if` statement can execute `exit 1` even when the value is actually configured. Since config values do not appear to become `nil` explicitly, use `nil?` to determine whether the value is configured. https://github.com/ruby/rubygems/commit/8fd32cb611 --- lib/bundler/cli/config.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/bundler/cli/config.rb b/lib/bundler/cli/config.rb index 8248e3b15b335f..976cda748466ce 100644 --- a/lib/bundler/cli/config.rb +++ b/lib/bundler/cli/config.rb @@ -97,10 +97,10 @@ def run confirm(name) end - if current_value - return - else + if current_value.nil? exit 1 + else + return end end From 0f618b87d55808b507d9a623116f62a4df655384 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Fri, 8 May 2026 18:09:22 +0900 Subject: [PATCH 4/6] [ruby/rubygems] Allow non-zero exit status in bundle config gemfile unset spec After 607648d5fc9 (`bundle config get` exits 1 when the value is unset), the spec added in 4658d6bd78b raises in the bundle helper because the new test invokes `config get gemfile` after unsetting it. Co-Authored-By: Claude Opus 4.7 (1M context) --- spec/bundler/commands/config_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/bundler/commands/config_spec.rb b/spec/bundler/commands/config_spec.rb index 0aaae98ccbc0bd..e8ab32ca5da12b 100644 --- a/spec/bundler/commands/config_spec.rb +++ b/spec/bundler/commands/config_spec.rb @@ -605,7 +605,7 @@ bundle "config set gemfile foo/bar_gemfile" bundle "config unset gemfile" - bundle "config get gemfile" + bundle "config get gemfile", raise_on_error: false expect(out).to include("You have not configured a value for `gemfile`") expect(File.read(bundled_app(".bundle/config"))).not_to include("BUNDLE_GEMFILE") From 4e243c709e45eb0d115b7875cae25dff86184b59 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Fri, 1 May 2026 13:39:03 +0900 Subject: [PATCH 5/6] pathname: Remove unneeded constant `SEPARATOR_LIST` is used only to initialize `SEPARATOR_PAT`. --- pathname_builtin.rb | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/pathname_builtin.rb b/pathname_builtin.rb index 60f936632fc120..d3da3158725bd9 100644 --- a/pathname_builtin.rb +++ b/pathname_builtin.rb @@ -349,16 +349,15 @@ def sub_ext(repl) if File::ALT_SEPARATOR # Separator list string. - SEPARATOR_LIST = Regexp.quote "#{File::ALT_SEPARATOR}#{File::SEPARATOR}" + separator_list = Regexp.quote "#{File::ALT_SEPARATOR}#{File::SEPARATOR}" # Regexp that matches a separator. - SEPARATOR_PAT = /[#{SEPARATOR_LIST}]/ + SEPARATOR_PAT = /[#{separator_list}]/ else - SEPARATOR_LIST = Regexp.quote File::SEPARATOR - SEPARATOR_PAT = /#{SEPARATOR_LIST}/ + separator_list = Regexp.quote File::SEPARATOR + SEPARATOR_PAT = /#{separator_list}/ end - SEPARATOR_LIST.freeze SEPARATOR_PAT.freeze - private_constant :SEPARATOR_LIST, :SEPARATOR_LIST + private_constant :SEPARATOR_PAT if File.dirname('A:') == 'A:.' # DOSish drive letter # Regexp that matches an absolute path. From 9fefb48643648234a71726e62ea7da2749cb85f4 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Fri, 8 May 2026 19:02:59 +0900 Subject: [PATCH 6/6] Use the bundled bundler Old bundler used the internal constant of Pathname, that was not private due to a typo. https://github.com/ruby/rubygems/pull/9529 --- .github/workflows/ubuntu.yml | 2 ++ .github/workflows/zjit-macos.yml | 2 ++ .github/workflows/zjit-ubuntu.yml | 2 ++ 3 files changed, 6 insertions(+) diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index 8bab57e65109ac..cff80e47c7ef28 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -251,6 +251,8 @@ jobs: - name: Run ruby-bench run: ruby run_benchmarks.rb -e "ruby::../build/install/bin/ruby" ${{ matrix.bench_opts }} working-directory: ruby-bench + env: + BUNDLER_VERSION: 0 - uses: ./.github/actions/slack with: diff --git a/.github/workflows/zjit-macos.yml b/.github/workflows/zjit-macos.yml index 97ee147ad3d0ee..1e57379e678fc0 100644 --- a/.github/workflows/zjit-macos.yml +++ b/.github/workflows/zjit-macos.yml @@ -225,6 +225,8 @@ jobs: - name: Run ruby-bench run: ruby run_benchmarks.rb -e "zjit::../build/install/bin/ruby ${{ matrix.ruby_opts }}" ${{ matrix.bench_opts }} working-directory: ruby-bench + env: + BUNDLER_VERSION: 0 - uses: ./.github/actions/slack with: diff --git a/.github/workflows/zjit-ubuntu.yml b/.github/workflows/zjit-ubuntu.yml index 2f3df123d401e6..633628f3e6ec08 100644 --- a/.github/workflows/zjit-ubuntu.yml +++ b/.github/workflows/zjit-ubuntu.yml @@ -279,6 +279,8 @@ jobs: - name: Run ruby-bench run: ruby run_benchmarks.rb -e "zjit::../build/install/bin/ruby ${{ matrix.ruby_opts }}" ${{ matrix.bench_opts }} working-directory: ruby-bench + env: + BUNDLER_VERSION: 0 - uses: ./.github/actions/slack with: