Skip to content

Commit 14b5817

Browse files
hsbtclaude
andcommitted
Fix uninstall_gem to set GEM_HOME instead of install_dir
Gem::Uninstaller with install_dir uses File.realpath for @gem_home but not for the specification_record path lookup, causing path mismatches on some CI environments. Instead, temporarily set GEM_HOME and call Gem.clear_paths to mimic the old subprocess-based gem_command behavior. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent e414c58 commit 14b5817

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

bundler/spec/support/helpers.rb

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -346,14 +346,19 @@ def uninstall_gem(name, options = {})
346346

347347
gem_home = options.dig(:env, "GEM_HOME") || system_gem_path.to_s
348348

349-
uninstaller = Gem::Uninstaller.new(
350-
name,
351-
install_dir: gem_home,
352-
ignore: true,
353-
executables: true,
354-
all: true
355-
)
356-
uninstaller.uninstall
349+
with_env_vars("GEM_HOME" => gem_home) do
350+
Gem.clear_paths
351+
352+
uninstaller = Gem::Uninstaller.new(
353+
name,
354+
ignore: true,
355+
executables: true,
356+
all: true
357+
)
358+
uninstaller.uninstall
359+
ensure
360+
Gem.clear_paths
361+
end
357362
end
358363

359364
def installed_gems_list(options = {})

0 commit comments

Comments
 (0)