From a75f979eec0717495c4f1559fecc635fbbb146af Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Thu, 17 Jan 2019 09:29:21 +0000 Subject: [PATCH] utils: re-add install_gem! version argument. This is needed for `compat/download_strategy` for now. --- Library/Homebrew/utils.rb | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb index b0ddf7e972..98677b1976 100644 --- a/Library/Homebrew/utils.rb +++ b/Library/Homebrew/utils.rb @@ -219,18 +219,21 @@ module Homebrew ENV["PATH"] = path end - def install_gem!(name) + # TODO: version can be removed when compat/download_strategy is deleted in 2.0 + def install_gem!(name, version = nil) setup_gem_environment! - return unless Gem::Specification.find_all_by_name(name).empty? + return unless Gem::Specification.find_all_by_name(name, version).empty? ohai "Installing or updating '#{name}' gem" + install_args = %W[--no-document #{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(["--no-document", name]) + install_cmd.handle_options(install_args) exit_code = 1 # Should not matter as `install_cmd.execute` always throws. begin install_cmd.execute