From 8963ddc3784542670f1ed50c7147d87327150b1d Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Fri, 4 Sep 2026 16:35:35 +0900 Subject: [PATCH] Stop depending on `getconf` in env helper specs Windows has no `getconf`, so these examples raise Errno::ENOENT on mswin unless MSYS2 or Git for Windows happens to be on PATH. Keep the current PATH as the base there, which also preserves the directories the Ruby under test loads its DLLs from. Co-Authored-By: Claude Opus 5 --- spec/runtime/env_helpers_spec.rb | 4 ++-- spec/support/helpers.rb | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/spec/runtime/env_helpers_spec.rb b/spec/runtime/env_helpers_spec.rb index c4ebdd1fd289..38f501e7cde6 100644 --- a/spec/runtime/env_helpers_spec.rb +++ b/spec/runtime/env_helpers_spec.rb @@ -21,7 +21,7 @@ def run_bundler_script(env, script) create_file("source.rb", <<-RUBY) print Bundler.original_env["PATH"] RUBY - path = `getconf PATH`.strip + "#{File::PATH_SEPARATOR}/foo" + path = default_system_path + "#{File::PATH_SEPARATOR}/foo" with_path_as(path) do bundle_exec_ruby(bundled_app("source.rb").to_s) expect(stdboth).to eq(path) @@ -49,7 +49,7 @@ def run_bundler_script(env, script) end exec(Gem.ruby, __FILE__, (count - 1).to_s) RUBY - path = `getconf PATH`.strip + File::PATH_SEPARATOR + File.dirname(Gem.ruby) + path = default_system_path + File::PATH_SEPARATOR + File.dirname(Gem.ruby) with_path_as(path) do build_bundler_context bundle_exec_ruby("#{bundled_app("exe.rb")} 2") diff --git a/spec/support/helpers.rb b/spec/support/helpers.rb index 8798cca57bb5..7925663dd1d1 100644 --- a/spec/support/helpers.rb +++ b/spec/support/helpers.rb @@ -428,6 +428,12 @@ def with_gem_path_as(path) end end + # Windows has no `getconf`, and its current PATH holds the directories the + # Ruby under test finds its DLLs in, so keep it as is there. + def default_system_path + Gem.win_platform? ? ENV["PATH"] : `getconf PATH`.strip + end + def with_path_as(path) without_env_side_effects do ENV["PATH"] = path.to_s