Remove existing from PATH when adding Gem.bindir.

This commit is contained in:
Markus Reiter 2017-05-03 10:18:07 +02:00
parent 6b005abd6a
commit 24b190cc14

View File

@ -189,14 +189,11 @@ module Homebrew
Gem.clear_paths Gem.clear_paths
Gem::Specification.reset Gem::Specification.reset
# Create GEM_HOME which may not exist yet so it exists when creating PATH.
FileUtils.mkdir_p Gem.bindir
# Add Gem binary directory and (if missing) Ruby binary directory to PATH. # Add Gem binary directory and (if missing) Ruby binary directory to PATH.
path = PATH.new(ENV["PATH"]) path = PATH.new(ENV["PATH"])
path.prepend(RUBY_BIN) if which("ruby") != RUBY_PATH path.prepend(RUBY_BIN) if which("ruby") != RUBY_PATH
path.prepend(Gem.bindir) path.prepend(Gem.bindir)
ENV["PATH"] = path.existing ENV["PATH"] = path
if Gem::Specification.find_all_by_name(name, version).empty? if Gem::Specification.find_all_by_name(name, version).empty?
ohai "Installing or updating '#{name}' gem" ohai "Installing or updating '#{name}' gem"