From e1bbab6ca6c8f96bb53fee9af3f0c01edd2d2f94 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Sun, 7 May 2017 17:28:37 +0100 Subject: Revert "Merge pull request #2603 from MikeMcQuaid/tweak-gem-vendoring" This reverts commit 2372872974d1049c2beafe7dedb7f8f882502058, reversing changes made to 3e4547f52e7ebec633f8bfefc8a396d944edf908. --- Library/Homebrew/utils.rb | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'Library/Homebrew/utils.rb') diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb index 6ae75a4fb..60af39d93 100644 --- a/Library/Homebrew/utils.rb +++ b/Library/Homebrew/utils.rb @@ -179,6 +179,48 @@ 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? -- cgit v1.2.3 From 57db2e539eaa5fbae351963265312bd24ed08f6b Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Sun, 7 May 2017 17:28:39 +0100 Subject: Revert "Merge pull request #2597 from MikeMcQuaid/vendor-gems" This reverts commit 3e4547f52e7ebec633f8bfefc8a396d944edf908, reversing changes made to 6edf9382bcc1240ad6f97c8b752cfe56cef9965d. --- Library/Homebrew/utils.rb | 32 -------------------------------- 1 file changed, 32 deletions(-) (limited to 'Library/Homebrew/utils.rb') diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb index 60af39d93..c37633e41 100644 --- a/Library/Homebrew/utils.rb +++ b/Library/Homebrew/utils.rb @@ -221,38 +221,6 @@ module Homebrew EOS end - def run_bundler_if_needed! - return unless Pathname.glob("#{HOMEBREW_GEM_HOME}/bin/*").empty? - - if Gem::Specification.find_all_by_name("bundler").empty? - ohai "Installing Bundler..." - - # 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(%w[--no-ri --no-rdoc bundler]) - 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 Bundler!" if exit_code.nonzero? - end - - HOMEBREW_REPOSITORY.cd do - unless quiet_system("bundle", "check") - ohai "Installing RubyGems..." - success = system "bundle", "install", - "--path", "Library/Homebrew/vendor", - "--standalone", - "--jobs", "3" - odie "Failed to install RubyGems!" unless success - end - end - end - # Hash of Module => Set(method_names) @injected_dump_stat_modules = {} -- cgit v1.2.3