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

Improve Bootsnap behaviour #10706

Merged
merged 1 commit into from
Feb 26, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
28 changes: 13 additions & 15 deletions Library/Homebrew/homebrew_bootsnap.rb
@@ -1,32 +1,30 @@
# typed: false
# frozen_string_literal: true

homebrew_bootsnap_enabled = !ENV["HOMEBREW_NO_BOOTSNAP"] &&
ENV["HOMEBREW_BOOTSNAP"] &&
# portable ruby doesn't play nice with bootsnap
!ENV["HOMEBREW_FORCE_VENDOR_RUBY"] &&
(!ENV["HOMEBREW_MACOS_VERSION"] || ENV["HOMEBREW_MACOS_SYSTEM_RUBY_NEW_ENOUGH"]) &&
# Apple Silicon doesn't play nice with bootsnap
(ENV["HOMEBREW_PROCESSOR"] == "Intel")

# we need some development tools to build bootsnap native code
development_tools_installed = if !homebrew_bootsnap_enabled
false
elsif RbConfig::CONFIG["host_os"].include? "darwin"
File.directory?("/Applications/Xcode.app") || File.directory?("/Library/Developer/CommandLineTools")
homebrew_bootsnap_enabled = !ENV["HOMEBREW_NO_BOOTSNAP"] && ENV["HOMEBREW_BOOTSNAP"]

# portable ruby doesn't play nice with bootsnap
# Can't use .exclude? here because we haven't required active_support yet.
homebrew_bootsnap_enabled &&= !ENV["HOMEBREW_RUBY_PATH"].to_s.include?("/vendor/portable-ruby/") # rubocop:disable Rails/NegateInclude

homebrew_bootsnap_enabled &&= if ENV["HOMEBREW_MACOS_VERSION"]
# Apple Silicon doesn't play nice with bootsnap
ENV["HOMEBREW_PROCESSOR"] == "Intel" &&
# we need some development tools to build bootsnap native code
(File.directory?("/Applications/Xcode.app") || File.directory?("/Library/Developer/CommandLineTools"))
else
File.executable?("/usr/bin/clang") || File.executable?("/usr/bin/gcc")
end

if homebrew_bootsnap_enabled && development_tools_installed
if homebrew_bootsnap_enabled
Comment on lines -21 to +19
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd still have the development_tools_installed and make that check only in the LoadError case, but it doesn't matter much.

require "rubygems"

begin
require "bootsnap"
rescue LoadError
unless ENV["HOMEBREW_BOOTSNAP_RETRY"]
require "utils/gems"
Homebrew.install_bundler_gems!
Homebrew.install_bundler_gems!(only_warn_on_failure: true)
Comment on lines -29 to +27
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, but probably quite noisy if it prints a massive block of warnings on every run?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup but I'm not sure what I see as a real workaround for that (particularly now it's no longer default as-of #10704)


ENV["HOMEBREW_BOOTSNAP_RETRY"] = "1"
exec ENV["HOMEBREW_BREW_FILE"], *ARGV
Expand Down