diff --git a/.gitignore b/.gitignore index 09e89c2216..7e5b4819fc 100644 --- a/.gitignore +++ b/.gitignore @@ -31,6 +31,7 @@ **/vendor/bundle/ruby/*/cache **/vendor/bundle/ruby/*/extensions **/vendor/bundle/ruby/*/gems/*/* +**/vendor/bundle/ruby/*/plugins **/vendor/bundle/ruby/*/specifications # Ignore YARD files diff --git a/Library/Homebrew/Gemfile b/Library/Homebrew/Gemfile index 917b7b6309..3d4f7e5298 100644 --- a/Library/Homebrew/Gemfile +++ b/Library/Homebrew/Gemfile @@ -42,7 +42,6 @@ end gem "activesupport" gem "addressable" gem "concurrent-ruby" -gem "did_you_mean" # remove when HOMEBREW_REQUIRED_RUBY_VERSION >= 2.7 gem "mechanize" gem "patchelf" gem "plist" @@ -52,3 +51,8 @@ gem "rubocop-rspec" gem "rubocop-sorbet" gem "ruby-macho" gem "sorbet-runtime" + +# remove when HOMEBREW_REQUIRED_RUBY_VERSION >= 2.7 +install_if -> { RUBY_VERSION < "2.7" } do + gem "did_you_mean" +end diff --git a/Library/Homebrew/utils/gems.rb b/Library/Homebrew/utils/gems.rb index ac9b69e7f0..2b5c7e5a2d 100644 --- a/Library/Homebrew/utils/gems.rb +++ b/Library/Homebrew/utils/gems.rb @@ -64,7 +64,7 @@ module Homebrew paths = ENV.fetch("PATH").split(":") paths.unshift(ruby_bindir) unless paths.include?(ruby_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(":") # Set envs so the above binaries can be invoked. @@ -80,8 +80,9 @@ module Homebrew if specs.empty? ohai_if_defined "Installing '#{name}' gem" - # document: [] , is equivalent to --no-document - specs = Gem.install name, version, document: [] + # `document: []` is equivalent to --no-document + # `build_args: []` stops ARGV being used as a default + specs = Gem.install name, version, document: [], build_args: [] end specs += specs.flat_map(&:runtime_dependencies) @@ -115,10 +116,6 @@ module Homebrew end 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! install_gem_setup_path!( "bundler",