Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove non-Portable Ruby bootsnap support #17534

Merged
merged 1 commit into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions Library/Homebrew/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 0 additions & 4 deletions Library/Homebrew/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -158,7 +155,6 @@ PLATFORMS

DEPENDENCIES
addressable
bootsnap
json_schemer
kramdown
method_source
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/env_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
1 change: 0 additions & 1 deletion Library/Homebrew/sorbet/tapioca/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ gem:
exclude:
# These conflict with the rbi files provided by sorbet:
- json
- msgpack
# These aren't needed:
- coderay
- commander
Expand Down
66 changes: 23 additions & 43 deletions Library/Homebrew/startup/bootsnap.rb
Original file line number Diff line number Diff line change
@@ -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)

Check warning on line 11 in Library/Homebrew/startup/bootsnap.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/startup/bootsnap.rb#L11

Added line #L11 was not covered by tests
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,

Check warning on line 19 in Library/Homebrew/startup/bootsnap.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/startup/bootsnap.rb#L18-L19

Added lines #L18 - L19 were not covered by tests
]

Bootsnap.setup(

Check warning on line 22 in Library/Homebrew/startup/bootsnap.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/startup/bootsnap.rb#L22

Added line #L22 was not covered by tests
cache_dir: cache,
ignore_directories:,
load_path_cache: true,
compile_cache_iseq: true,
compile_cache_yaml: true,
)
end
1 change: 0 additions & 1 deletion Library/Homebrew/utils/gems.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
4 changes: 2 additions & 2 deletions docs/Manpage.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`

Expand Down
2 changes: 1 addition & 1 deletion manpages/brew.1
Original file line number Diff line number Diff line change
Expand Up @@ -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\.
Expand Down
Loading