diff --git a/lib/rubygems/commands/exec_command.rb b/lib/rubygems/commands/exec_command.rb index 463308627a..87c1cf9051 100644 --- a/lib/rubygems/commands/exec_command.rb +++ b/lib/rubygems/commands/exec_command.rb @@ -56,12 +56,13 @@ to the same gem path as user-installed gems. end def execute - gem_paths = { "GEM_HOME": Gem.paths.home, "GEM_PATH": Gem.paths.path, "GEM_SPEC_CACHE": Gem.paths.spec_cache_dir } + gem_paths = { "GEM_HOME" => Gem.paths.home, "GEM_PATH" => Gem.paths.path.join(Gem.path_separator), "GEM_SPEC_CACHE" => Gem.paths.spec_cache_dir } check_executable print_command if options[:gem_name] == "gem" && options[:executable] == "gem" + set_gem_exec_install_paths Gem::GemRunner.new.run options[:args] return elsif options[:conservative] @@ -73,7 +74,8 @@ to the same gem path as user-installed gems. load! ensure - Gem.paths = gem_paths + ENV.update(gem_paths) + Gem.clear_paths end private diff --git a/test/rubygems/test_gem_commands_exec_command.rb b/test/rubygems/test_gem_commands_exec_command.rb index d4f8827808..4b9bacaa1a 100644 --- a/test/rubygems/test_gem_commands_exec_command.rb +++ b/test/rubygems/test_gem_commands_exec_command.rb @@ -739,7 +739,7 @@ class TestGemCommandsExecCommand < Gem::TestCase assert_match /\A\s*\** LOCAL GEMS \**\s*\z/m, @ui.output invoke "gem", "env", "GEM_HOME" - assert_match /#{File::SEPARATOR}gem_exec$/, @ui.output + assert_equal "#{@gem_home}/gem_exec\n", @ui.output end end end