Revert "Merge pull request #2603 from MikeMcQuaid/tweak-gem-vendoring"
This reverts commit 2372872974d1049c2beafe7dedb7f8f882502058, reversing changes made to 3e4547f52e7ebec633f8bfefc8a396d944edf908.
This commit is contained in:
parent
a76392dd5f
commit
e1bbab6ca6
@ -8,13 +8,13 @@ std_trap = trap("INT") { exit! 130 } # no backtrace thanks
|
|||||||
RUBY_TWO = RUBY_VERSION.split(".").first.to_i >= 2
|
RUBY_TWO = RUBY_VERSION.split(".").first.to_i >= 2
|
||||||
raise "Homebrew must be run under Ruby 2!" unless RUBY_TWO
|
raise "Homebrew must be run under Ruby 2!" unless RUBY_TWO
|
||||||
|
|
||||||
require "pathname"
|
homebrew_library_path = File.dirname(File.realpath(__FILE__))
|
||||||
HOMEBREW_LIBRARY_PATH = Pathname.new(__FILE__).realpath.parent
|
$:.unshift(homebrew_library_path)
|
||||||
$:.unshift(HOMEBREW_LIBRARY_PATH)
|
|
||||||
|
|
||||||
load_path_before_bundler = $:.dup
|
require_relative "#{homebrew_library_path}/vendor/bundler/setup"
|
||||||
require_relative "#{HOMEBREW_LIBRARY_PATH}/vendor/bundler/setup"
|
|
||||||
ENV["HOMEBREW_GEMS_LOAD_PATH"] = ($: - load_path_before_bundler).join(":")
|
require "pathname"
|
||||||
|
HOMEBREW_LIBRARY_PATH = Pathname.new(homebrew_library_path)
|
||||||
|
|
||||||
require "global"
|
require "global"
|
||||||
require "tap"
|
require "tap"
|
||||||
@ -25,6 +25,8 @@ if ARGV == %w[--version] || ARGV == %w[-v]
|
|||||||
exit 0
|
exit 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
HOMEBREW_GEM_HOME = HOMEBREW_LIBRARY_PATH/"vendor/#{RUBY_ENGINE}/#{RUBY_VERSION}"
|
||||||
|
|
||||||
def require?(path)
|
def require?(path)
|
||||||
require path
|
require path
|
||||||
rescue LoadError => e
|
rescue LoadError => e
|
||||||
@ -58,21 +60,18 @@ begin
|
|||||||
path.append(Pathname.glob(Tap::TAP_DIRECTORY/"*/*/cmd"))
|
path.append(Pathname.glob(Tap::TAP_DIRECTORY/"*/*/cmd"))
|
||||||
|
|
||||||
# Add RubyGems.
|
# Add RubyGems.
|
||||||
HOMEBREW_GEM_HOME = HOMEBREW_LIBRARY_PATH/"vendor/#{RUBY_ENGINE}/#{RUBY_VERSION}"
|
ENV["GEM_HOME"] = ENV["GEM_PATH"] = HOMEBREW_GEM_HOME
|
||||||
path.append(HOMEBREW_GEM_HOME/"bin")
|
path.append(HOMEBREW_GEM_HOME/"bin")
|
||||||
|
|
||||||
|
# Make RubyGems notice environment changes.
|
||||||
|
Gem.clear_paths
|
||||||
|
Gem::Specification.reset
|
||||||
|
|
||||||
# Add SCM wrappers.
|
# Add SCM wrappers.
|
||||||
path.append(HOMEBREW_SHIMS_PATH/"scm")
|
path.append(HOMEBREW_SHIMS_PATH/"scm")
|
||||||
|
|
||||||
ENV["PATH"] = path
|
ENV["PATH"] = path
|
||||||
|
|
||||||
# Setup RubyGems environment.
|
|
||||||
ENV["GEM_HOME"] = ENV["GEM_PATH"] = HOMEBREW_GEM_HOME
|
|
||||||
# Make RubyGems notice environment changes.
|
|
||||||
Gem.clear_paths
|
|
||||||
Gem::Specification.reset
|
|
||||||
Homebrew.run_bundler_if_needed! unless HOMEBREW_GEM_HOME.exist?
|
|
||||||
|
|
||||||
if cmd
|
if cmd
|
||||||
internal_cmd = require? HOMEBREW_LIBRARY_PATH.join("cmd", cmd)
|
internal_cmd = require? HOMEBREW_LIBRARY_PATH.join("cmd", cmd)
|
||||||
|
|
||||||
|
@ -69,6 +69,10 @@ then
|
|||||||
odie "Cowardly refusing to continue at this prefix: $HOMEBREW_PREFIX"
|
odie "Cowardly refusing to continue at this prefix: $HOMEBREW_PREFIX"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Save value to use for installing gems
|
||||||
|
export GEM_OLD_HOME="$GEM_HOME"
|
||||||
|
export GEM_OLD_PATH="$GEM_PATH"
|
||||||
|
|
||||||
# Users may have these set, pointing the system Ruby
|
# Users may have these set, pointing the system Ruby
|
||||||
# at non-system gem paths
|
# at non-system gem paths
|
||||||
unset GEM_HOME
|
unset GEM_HOME
|
||||||
|
@ -46,8 +46,5 @@ unless defined? HOMEBREW_LIBRARY_PATH
|
|||||||
HOMEBREW_LIBRARY_PATH = Pathname.new(__FILE__).realpath.parent
|
HOMEBREW_LIBRARY_PATH = Pathname.new(__FILE__).realpath.parent
|
||||||
end
|
end
|
||||||
|
|
||||||
# Load path to vendored gems used by Homebrew
|
|
||||||
HOMEBREW_GEMS_LOAD_PATH = ENV["HOMEBREW_GEMS_LOAD_PATH"]
|
|
||||||
|
|
||||||
# Load path used by standalone scripts to access the Homebrew code base
|
# Load path used by standalone scripts to access the Homebrew code base
|
||||||
HOMEBREW_LOAD_PATH = [HOMEBREW_LIBRARY_PATH, *HOMEBREW_GEMS_LOAD_PATH].join(":")
|
HOMEBREW_LOAD_PATH = HOMEBREW_LIBRARY_PATH
|
||||||
|
@ -1,11 +1,10 @@
|
|||||||
|
require "macho"
|
||||||
require "os/mac/architecture_list"
|
require "os/mac/architecture_list"
|
||||||
|
|
||||||
module MachOShim
|
module MachOShim
|
||||||
# @private
|
# @private
|
||||||
def macho
|
def macho
|
||||||
@macho ||= begin
|
@macho ||= begin
|
||||||
require "macho"
|
|
||||||
|
|
||||||
MachO.open(to_s)
|
MachO.open(to_s)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -13,8 +12,6 @@ module MachOShim
|
|||||||
# @private
|
# @private
|
||||||
def mach_data
|
def mach_data
|
||||||
@mach_data ||= begin
|
@mach_data ||= begin
|
||||||
require "macho"
|
|
||||||
|
|
||||||
machos = []
|
machos = []
|
||||||
mach_data = []
|
mach_data = []
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ end
|
|||||||
# Paths pointing into the Homebrew code base that persist across test runs
|
# Paths pointing into the Homebrew code base that persist across test runs
|
||||||
HOMEBREW_LIBRARY_PATH = Pathname.new(File.expand_path("../../../..", __FILE__))
|
HOMEBREW_LIBRARY_PATH = Pathname.new(File.expand_path("../../../..", __FILE__))
|
||||||
HOMEBREW_SHIMS_PATH = HOMEBREW_LIBRARY_PATH.parent+"Homebrew/shims"
|
HOMEBREW_SHIMS_PATH = HOMEBREW_LIBRARY_PATH.parent+"Homebrew/shims"
|
||||||
HOMEBREW_LOAD_PATH = [File.expand_path("..", __FILE__), HOMEBREW_LIBRARY_PATH, ENV["HOMEBREW_GEMS_LOAD_PATH"]].join(":")
|
HOMEBREW_LOAD_PATH = [File.expand_path("..", __FILE__), HOMEBREW_LIBRARY_PATH].join(":")
|
||||||
|
|
||||||
# Paths redirected to a temporary directory and wiped at the end of the test run
|
# Paths redirected to a temporary directory and wiped at the end of the test run
|
||||||
HOMEBREW_PREFIX = Pathname.new(TEST_TMPDIR).join("prefix")
|
HOMEBREW_PREFIX = Pathname.new(TEST_TMPDIR).join("prefix")
|
||||||
|
@ -179,6 +179,48 @@ module Homebrew
|
|||||||
_system(cmd, *args)
|
_system(cmd, *args)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def install_gem_setup_path!(name, version = nil, executable = name)
|
||||||
|
# Respect user's preferences for where gems should be installed.
|
||||||
|
ENV["GEM_HOME"] = ENV["GEM_OLD_HOME"].to_s
|
||||||
|
ENV["GEM_HOME"] = Gem.user_dir if ENV["GEM_HOME"].empty?
|
||||||
|
ENV["GEM_PATH"] = ENV["GEM_OLD_PATH"] unless ENV["GEM_OLD_PATH"].to_s.empty?
|
||||||
|
|
||||||
|
# Make rubygems notice env changes.
|
||||||
|
Gem.clear_paths
|
||||||
|
Gem::Specification.reset
|
||||||
|
|
||||||
|
# Add Gem binary directory and (if missing) Ruby binary directory to PATH.
|
||||||
|
path = PATH.new(ENV["PATH"])
|
||||||
|
path.prepend(RUBY_BIN) if which("ruby") != RUBY_PATH
|
||||||
|
path.prepend(Gem.bindir)
|
||||||
|
ENV["PATH"] = path
|
||||||
|
|
||||||
|
if Gem::Specification.find_all_by_name(name, version).empty?
|
||||||
|
ohai "Installing or updating '#{name}' gem"
|
||||||
|
install_args = %W[--no-ri --no-rdoc #{name}]
|
||||||
|
install_args << "--version" << version if version
|
||||||
|
|
||||||
|
# Do `gem install [...]` without having to spawn a separate process or
|
||||||
|
# having to find the right `gem` binary for the running Ruby interpreter.
|
||||||
|
require "rubygems/commands/install_command"
|
||||||
|
install_cmd = Gem::Commands::InstallCommand.new
|
||||||
|
install_cmd.handle_options(install_args)
|
||||||
|
exit_code = 1 # Should not matter as `install_cmd.execute` always throws.
|
||||||
|
begin
|
||||||
|
install_cmd.execute
|
||||||
|
rescue Gem::SystemExitException => e
|
||||||
|
exit_code = e.exit_code
|
||||||
|
end
|
||||||
|
odie "Failed to install/update the '#{name}' gem." if exit_code.nonzero?
|
||||||
|
end
|
||||||
|
|
||||||
|
return if which(executable)
|
||||||
|
odie <<-EOS.undent
|
||||||
|
The '#{name}' gem is installed but couldn't find '#{executable}' in the PATH:
|
||||||
|
#{ENV["PATH"]}
|
||||||
|
EOS
|
||||||
|
end
|
||||||
|
|
||||||
def run_bundler_if_needed!
|
def run_bundler_if_needed!
|
||||||
return unless Pathname.glob("#{HOMEBREW_GEM_HOME}/bin/*").empty?
|
return unless Pathname.glob("#{HOMEBREW_GEM_HOME}/bin/*").empty?
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user