Allow gem installation on Rubies other than 2.6

This commit is contained in:
Bo Anderson 2022-10-17 22:24:08 +01:00
parent 9b318a54d0
commit 796bad98ff
No known key found for this signature in database
GPG Key ID: 3DB94E204E137D65
3 changed files with 10 additions and 8 deletions

1
.gitignore vendored
View File

@ -31,6 +31,7 @@
**/vendor/bundle/ruby/*/cache **/vendor/bundle/ruby/*/cache
**/vendor/bundle/ruby/*/extensions **/vendor/bundle/ruby/*/extensions
**/vendor/bundle/ruby/*/gems/*/* **/vendor/bundle/ruby/*/gems/*/*
**/vendor/bundle/ruby/*/plugins
**/vendor/bundle/ruby/*/specifications **/vendor/bundle/ruby/*/specifications
# Ignore YARD files # Ignore YARD files

View File

@ -42,7 +42,6 @@ end
gem "activesupport" gem "activesupport"
gem "addressable" gem "addressable"
gem "concurrent-ruby" gem "concurrent-ruby"
gem "did_you_mean" # remove when HOMEBREW_REQUIRED_RUBY_VERSION >= 2.7
gem "mechanize" gem "mechanize"
gem "patchelf" gem "patchelf"
gem "plist" gem "plist"
@ -52,3 +51,8 @@ gem "rubocop-rspec"
gem "rubocop-sorbet" gem "rubocop-sorbet"
gem "ruby-macho" gem "ruby-macho"
gem "sorbet-runtime" gem "sorbet-runtime"
# remove when HOMEBREW_REQUIRED_RUBY_VERSION >= 2.7
install_if -> { RUBY_VERSION < "2.7" } do
gem "did_you_mean"
end

View File

@ -64,7 +64,7 @@ module Homebrew
paths = ENV.fetch("PATH").split(":") paths = ENV.fetch("PATH").split(":")
paths.unshift(ruby_bindir) unless paths.include?(ruby_bindir) paths.unshift(ruby_bindir) unless paths.include?(ruby_bindir)
paths.unshift(Gem.bindir) unless paths.include?(Gem.bindir) paths.unshift(Gem.bindir) unless paths.include?(Gem.bindir)
paths.unshift(HOMEBREW_SHIMS_PATH/"ruby") unless paths.include?(HOMEBREW_SHIMS_PATH/"ruby") paths.unshift(HOMEBREW_LIBRARY_PATH/"shims/ruby") unless paths.include?(HOMEBREW_LIBRARY_PATH/"shims/ruby")
ENV["PATH"] = paths.compact.join(":") ENV["PATH"] = paths.compact.join(":")
# Set envs so the above binaries can be invoked. # Set envs so the above binaries can be invoked.
@ -80,8 +80,9 @@ module Homebrew
if specs.empty? if specs.empty?
ohai_if_defined "Installing '#{name}' gem" ohai_if_defined "Installing '#{name}' gem"
# document: [] , is equivalent to --no-document # `document: []` is equivalent to --no-document
specs = Gem.install name, version, document: [] # `build_args: []` stops ARGV being used as a default
specs = Gem.install name, version, document: [], build_args: []
end end
specs += specs.flat_map(&:runtime_dependencies) specs += specs.flat_map(&:runtime_dependencies)
@ -115,10 +116,6 @@ module Homebrew
end end
def install_bundler! def install_bundler!
if Gem.ruby_version >= Gem::Version.new("2.7")
raise "Installing and using Bundler is currently only supported on Ruby 2.6."
end
setup_gem_environment! setup_gem_environment!
install_gem_setup_path!( install_gem_setup_path!(
"bundler", "bundler",