From a7405601f376d4c3355c003146a8ec61f384b197 Mon Sep 17 00:00:00 2001 From: rmnull Date: Thu, 4 Jun 2020 11:36:58 +0530 Subject: [PATCH] Use `Gem` to install gems instead of invoking `system` --- Library/Homebrew/utils/gems.rb | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/Library/Homebrew/utils/gems.rb b/Library/Homebrew/utils/gems.rb index 16c8452990..8fba9b3096 100644 --- a/Library/Homebrew/utils/gems.rb +++ b/Library/Homebrew/utils/gems.rb @@ -66,12 +66,10 @@ module Homebrew setup_gem_environment! if setup_gem_environment return unless Gem::Specification.find_all_by_name(name, version).empty? - # Shell out to `gem` to avoid RubyGems requires for e.g. loading JSON. ohai_if_defined "Installing '#{name}' gem" - install_args = %W[--no-document #{name}] - install_args << "--version" << version if version - return if system "#{ruby_bindir}/gem", "install", *install_args - + # document: [] , is equivalent to --no-document + Gem.install name, version, document: [] + rescue Gem::UnsatisfiableDependencyError odie_if_defined "failed to install the '#{name}' gem." end