From 2b454328ca79fde6a98e9c6317141c828a92f016 Mon Sep 17 00:00:00 2001 From: Bo Anderson Date: Wed, 19 Jun 2024 16:08:05 +0100 Subject: [PATCH] Remove non-Portable Ruby bootsnap support --- Library/Homebrew/Gemfile | 3 - Library/Homebrew/Gemfile.lock | 4 -- Library/Homebrew/env_config.rb | 2 +- Library/Homebrew/sorbet/tapioca/config.yml | 1 - Library/Homebrew/startup/bootsnap.rb | 66 +++++++------------ .../startup/{bootstrap.rbi => bootsnap.rbi} | 0 Library/Homebrew/utils/gems.rb | 1 - docs/Manpage.md | 4 +- manpages/brew.1 | 2 +- 9 files changed, 27 insertions(+), 56 deletions(-) rename Library/Homebrew/startup/{bootstrap.rbi => bootsnap.rbi} (100%) diff --git a/Library/Homebrew/Gemfile b/Library/Homebrew/Gemfile index d12460c39dd55..5a18416398586 100644 --- a/Library/Homebrew/Gemfile +++ b/Library/Homebrew/Gemfile @@ -23,9 +23,6 @@ end group :ast, optional: true do gem "rubocop-ast", require: false end -group :bootsnap, optional: true do - gem "bootsnap", require: false -end group :formula_test, optional: true do gem "minitest", require: false end diff --git a/Library/Homebrew/Gemfile.lock b/Library/Homebrew/Gemfile.lock index b2a8ff4314f47..1b29b049fe595 100644 --- a/Library/Homebrew/Gemfile.lock +++ b/Library/Homebrew/Gemfile.lock @@ -6,8 +6,6 @@ GEM ast (2.4.2) bigdecimal (3.1.8) bindata (2.5.0) - bootsnap (1.18.3) - msgpack (~> 1.2) coderay (1.1.3) commander (5.0.0) highline (~> 3.0.0) @@ -29,7 +27,6 @@ GEM language_server-protocol (3.17.0.3) method_source (1.1.0) minitest (5.23.1) - msgpack (1.7.2) netrc (0.11.0) parallel (1.25.1) parallel_tests (4.7.1) @@ -158,7 +155,6 @@ PLATFORMS DEPENDENCIES addressable - bootsnap json_schemer kramdown method_source diff --git a/Library/Homebrew/env_config.rb b/Library/Homebrew/env_config.rb index 9a33b83c3a46a..d77c1c539984e 100644 --- a/Library/Homebrew/env_config.rb +++ b/Library/Homebrew/env_config.rb @@ -69,7 +69,7 @@ module EnvConfig }, HOMEBREW_BOOTSNAP: { description: "If set, use Bootsnap to speed up repeated `brew` calls. " \ - "A no-op when using Homebrew's vendored, relocatable Ruby on macOS (as it doesn't work).", + "A no-op on Linux when not using Homebrew's vendored, relocatable Ruby.", boolean: true, }, HOMEBREW_BOTTLE_DOMAIN: { diff --git a/Library/Homebrew/sorbet/tapioca/config.yml b/Library/Homebrew/sorbet/tapioca/config.yml index 54d00d518c0a6..2c5fd5823b8e2 100644 --- a/Library/Homebrew/sorbet/tapioca/config.yml +++ b/Library/Homebrew/sorbet/tapioca/config.yml @@ -4,7 +4,6 @@ gem: exclude: # These conflict with the rbi files provided by sorbet: - json - - msgpack # These aren't needed: - coderay - commander diff --git a/Library/Homebrew/startup/bootsnap.rb b/Library/Homebrew/startup/bootsnap.rb index 29bdd6983ea2d..9bb8b139a6d7e 100644 --- a/Library/Homebrew/startup/bootsnap.rb +++ b/Library/Homebrew/startup/bootsnap.rb @@ -1,49 +1,29 @@ # typed: strict # frozen_string_literal: true -homebrew_bootsnap_enabled = ENV["HOMEBREW_NO_BOOTSNAP"].nil? && !ENV["HOMEBREW_BOOTSNAP"].nil? - -# we need some development tools to build bootsnap native code -homebrew_bootsnap_enabled &&= if ENV["HOMEBREW_MACOS_VERSION"] - File.directory?("/Applications/Xcode.app") || File.directory?("/Library/Developer/CommandLineTools") -else - File.executable?("/usr/bin/clang") || File.executable?("/usr/bin/gcc") -end +homebrew_bootsnap_enabled = HOMEBREW_USING_PORTABLE_RUBY && + ENV["HOMEBREW_NO_BOOTSNAP"].nil? && + !ENV["HOMEBREW_BOOTSNAP"].nil? if homebrew_bootsnap_enabled - begin - require "bootsnap" - rescue LoadError - raise if ENV["HOMEBREW_BOOTSNAP_RETRY"] || HOMEBREW_USING_PORTABLE_RUBY - - Homebrew.install_bundler_gems!(groups: ["bootsnap"], only_warn_on_failure: true) - - ENV["HOMEBREW_BOOTSNAP_RETRY"] = "1" - exec ENV.fetch("HOMEBREW_BREW_FILE"), *ARGV - end - - ENV.delete("HOMEBREW_BOOTSNAP_RETRY") - - if defined?(Bootsnap) - cache = ENV.fetch("HOMEBREW_CACHE", nil) || ENV.fetch("HOMEBREW_DEFAULT_CACHE", nil) - raise "Needs HOMEBREW_CACHE or HOMEBREW_DEFAULT_CACHE!" if cache.nil? || cache.empty? - - # We never do `require "vendor/bundle/ruby/..."` or `require "vendor/portable-ruby/..."`, - # so let's slim the cache a bit by excluding them. - # Note that gems within `bundle/ruby` will still be cached - these are when directory walking down from above. - ignore_directories = [ - (HOMEBREW_LIBRARY_PATH/"vendor/bundle/ruby").to_s, - (HOMEBREW_LIBRARY_PATH/"vendor/portable-ruby").to_s, - ] - - Bootsnap.setup( - cache_dir: cache, - ignore_directories:, - load_path_cache: true, - compile_cache_iseq: true, - compile_cache_yaml: true, - ) - else - $stderr.puts "Error: HOMEBREW_BOOTSNAP could not `require \"bootsnap\"`!\n\n" - end + require "bootsnap" + + cache = ENV.fetch("HOMEBREW_CACHE", nil) || ENV.fetch("HOMEBREW_DEFAULT_CACHE", nil) + raise "Needs HOMEBREW_CACHE or HOMEBREW_DEFAULT_CACHE!" if cache.nil? || cache.empty? + + # We never do `require "vendor/bundle/ruby/..."` or `require "vendor/portable-ruby/..."`, + # so let's slim the cache a bit by excluding them. + # Note that gems within `bundle/ruby` will still be cached - these are when directory walking down from above. + ignore_directories = [ + (HOMEBREW_LIBRARY_PATH/"vendor/bundle/ruby").to_s, + (HOMEBREW_LIBRARY_PATH/"vendor/portable-ruby").to_s, + ] + + Bootsnap.setup( + cache_dir: cache, + ignore_directories:, + load_path_cache: true, + compile_cache_iseq: true, + compile_cache_yaml: true, + ) end diff --git a/Library/Homebrew/startup/bootstrap.rbi b/Library/Homebrew/startup/bootsnap.rbi similarity index 100% rename from Library/Homebrew/startup/bootstrap.rbi rename to Library/Homebrew/startup/bootsnap.rbi diff --git a/Library/Homebrew/utils/gems.rb b/Library/Homebrew/utils/gems.rb index 717a5a006c651..585cfdb94bf93 100644 --- a/Library/Homebrew/utils/gems.rb +++ b/Library/Homebrew/utils/gems.rb @@ -241,7 +241,6 @@ def install_bundler_gems!(only_warn_on_failure: false, setup_path: true, groups: # Combine the passed groups with the ones stored in settings. groups |= (user_gem_groups & valid_gem_groups) - groups.delete("bootsnap") if HOMEBREW_USING_PORTABLE_RUBY groups.sort! if (homebrew_bundle_user_cache = ENV.fetch("HOMEBREW_BUNDLE_USER_CACHE", nil)) diff --git a/docs/Manpage.md b/docs/Manpage.md index a26e4165a8d84..948369457af88 100644 --- a/docs/Manpage.md +++ b/docs/Manpage.md @@ -3563,8 +3563,8 @@ command execution e.g. `$(cat file)`. `HOMEBREW_BOOTSNAP` -: If set, use Bootsnap to speed up repeated `brew` calls. A no-op when using - Homebrew's vendored, relocatable Ruby on macOS (as it doesn't work). +: If set, use Bootsnap to speed up repeated `brew` calls. A no-op on Linux when + not using Homebrew's vendored, relocatable Ruby. `HOMEBREW_BOTTLE_DOMAIN` diff --git a/manpages/brew.1 b/manpages/brew.1 index b0207e1d06327..fed9be61a20d9 100644 --- a/manpages/brew.1 +++ b/manpages/brew.1 @@ -2285,7 +2285,7 @@ Use this as the \fBbat\fP theme for syntax highlighting\. .RE .TP \fBHOMEBREW_BOOTSNAP\fP -If set, use Bootsnap to speed up repeated \fBbrew\fP calls\. A no\-op when using Homebrew\[u2019]s vendored, relocatable Ruby on macOS (as it doesn\[u2019]t work)\. +If set, use Bootsnap to speed up repeated \fBbrew\fP calls\. A no\-op on Linux when not using Homebrew\[u2019]s vendored, relocatable Ruby\. .TP \fBHOMEBREW_BOTTLE_DOMAIN\fP Use this URL as the download mirror for bottles\. If bottles at that URL are temporarily unavailable, the default bottle domain will be used as a fallback mirror\. For example, \fBHOMEBREW_BOTTLE_DOMAIN=http://localhost:8080\fP will cause all bottles to download from the prefix \fBhttp://localhost:8080/\fP\&\. If bottles are not available at \fBHOMEBREW_BOTTLE_DOMAIN\fP they will be downloaded from the default bottle domain\.