From ee253e465b8e2f5acdb53daf572311e87055e082 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Sun, 7 May 2017 13:52:57 +0100 Subject: Vendor all Homebrew's gems. Homebrew's actually ended up using a fair few gems. While we want to avoid Bundler at runtime (and this PR still does that, in fact uses Bundler even less at runtime than it did before) writing our own version to use at build-time seems redundant. --- Library/Homebrew/brew.rb | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'Library/Homebrew/brew.rb') diff --git a/Library/Homebrew/brew.rb b/Library/Homebrew/brew.rb index e07599ac6..6dab50f29 100644 --- a/Library/Homebrew/brew.rb +++ b/Library/Homebrew/brew.rb @@ -8,9 +8,14 @@ std_trap = trap("INT") { exit! 130 } # no backtrace thanks RUBY_TWO = RUBY_VERSION.split(".").first.to_i >= 2 raise "Homebrew must be run under Ruby 2!" unless RUBY_TWO +homebrew_library_path = File.dirname(File.realpath(__FILE__)) +$:.unshift(homebrew_library_path) + +require_relative "#{homebrew_library_path}/vendor/bundler/setup" + require "pathname" -HOMEBREW_LIBRARY_PATH = Pathname.new(__FILE__).realpath.parent -$:.unshift(HOMEBREW_LIBRARY_PATH.to_s) +HOMEBREW_LIBRARY_PATH = Pathname.new(homebrew_library_path) + require "global" require "tap" @@ -20,6 +25,8 @@ if ARGV == %w[--version] || ARGV == %w[-v] exit 0 end +HOMEBREW_GEM_HOME = HOMEBREW_LIBRARY_PATH/"vendor/#{RUBY_ENGINE}/#{RUBY_VERSION}" + def require?(path) require path rescue LoadError => e @@ -52,6 +59,14 @@ begin # Add contributed commands to PATH before checking. path.append(Pathname.glob(Tap::TAP_DIRECTORY/"*/*/cmd")) + # Add RubyGems. + ENV["GEM_HOME"] = ENV["GEM_PATH"] = HOMEBREW_GEM_HOME + path.append(HOMEBREW_GEM_HOME/"bin") + + # Make RubyGems notice environment changes. + Gem.clear_paths + Gem::Specification.reset + # Add SCM wrappers. path.append(HOMEBREW_SHIMS_PATH/"scm") -- cgit v1.2.3