aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/utils.rb
diff options
context:
space:
mode:
authorMike McQuaid2017-05-07 15:33:54 +0100
committerMike McQuaid2017-05-07 15:33:54 +0100
commit33f83be10e5256ce628cb128f25d0a9f399d37ef (patch)
tree1f2f4ad3d7376208bf280486474e62293c43f204 /Library/Homebrew/utils.rb
parent3e4547f52e7ebec633f8bfefc8a396d944edf908 (diff)
downloadbrew-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/utils.rb')
-rw-r--r--Library/Homebrew/utils.rb42
1 files changed, 0 insertions, 42 deletions
diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb
index 60af39d93..6ae75a4fb 100644
--- a/Library/Homebrew/utils.rb
+++ b/Library/Homebrew/utils.rb
@@ -179,48 +179,6 @@ module Homebrew
_system(cmd, *args)
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!
return unless Pathname.glob("#{HOMEBREW_GEM_HOME}/bin/*").empty?