diff options
| author | Mike McQuaid | 2017-05-07 15:33:54 +0100 |
|---|---|---|
| committer | Mike McQuaid | 2017-05-07 15:33:54 +0100 |
| commit | 33f83be10e5256ce628cb128f25d0a9f399d37ef (patch) | |
| tree | 1f2f4ad3d7376208bf280486474e62293c43f204 /Library/Homebrew/brew.rb | |
| parent | 3e4547f52e7ebec633f8bfefc8a396d944edf908 (diff) | |
| download | brew-33f83be10e5256ce628cb128f25d0a9f399d37ef.tar.bz2 | |
Tweak Gem vendoring.
If people have `HOMEBREW_RUBY_PATH` set then things explode in a rather
confusing fashion. Instead, run `bundle` for them with the arguments
that they'd want.
Also, move `macho` requires into the module itself; it's a pain having
to do everything for Bundler before requiring `pathname` which is a core
Ruby class.
Diffstat (limited to 'Library/Homebrew/brew.rb')
| -rw-r--r-- | Library/Homebrew/brew.rb | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/Library/Homebrew/brew.rb b/Library/Homebrew/brew.rb index 6dab50f29..e19819cf5 100644 --- a/Library/Homebrew/brew.rb +++ b/Library/Homebrew/brew.rb @@ -8,13 +8,13 @@ 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(homebrew_library_path) +HOMEBREW_LIBRARY_PATH = Pathname.new(__FILE__).realpath.parent +$:.unshift(HOMEBREW_LIBRARY_PATH) + +load_path_before_bundler = $:.dup +require_relative "#{HOMEBREW_LIBRARY_PATH}/vendor/bundler/setup" +ENV["HOMEBREW_GEMS_LOAD_PATH"] = ($: - load_path_before_bundler).join(":") require "global" require "tap" @@ -25,8 +25,6 @@ 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 @@ -60,18 +58,21 @@ begin path.append(Pathname.glob(Tap::TAP_DIRECTORY/"*/*/cmd")) # Add RubyGems. - ENV["GEM_HOME"] = ENV["GEM_PATH"] = HOMEBREW_GEM_HOME + HOMEBREW_GEM_HOME = HOMEBREW_LIBRARY_PATH/"vendor/#{RUBY_ENGINE}/#{RUBY_VERSION}" 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") 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 internal_cmd = require? HOMEBREW_LIBRARY_PATH.join("cmd", cmd) |
