Use Gem to install gems instead of invoking system

This commit is contained in:
rmnull 2020-06-04 11:36:58 +05:30
parent 4c49224193
commit a7405601f3
No known key found for this signature in database
GPG Key ID: 35BAB82D31EFAD91

View File

@ -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