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: diff --git a/lib/bundler/cli/config.rb b/lib/bundler/cli/config.rb index 6a77e4a65ea386..976cda748466ce 100644 --- a/lib/bundler/cli/config.rb +++ b/lib/bundler/cli/config.rb @@ -87,16 +87,21 @@ def run if value.nil? warn_unused_scope "Ignoring --#{scope} since no value to set was given" + current_value = Bundler.settings[name] if options[:parseable] if value = Bundler.settings[name] Bundler.ui.info("#{name}=#{value}") end - return + else + confirm(name) end - confirm(name) - return + if current_value.nil? + exit 1 + else + return + end end Bundler.ui.info(message) if message 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. 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..e8ab32ca5da12b 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 @@ -600,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") 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