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

homebrew_bootsnap: fail more gracefully. #10538

Merged
merged 1 commit into from Feb 5, 2021
Merged
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
36 changes: 20 additions & 16 deletions Library/Homebrew/homebrew_bootsnap.rb
Expand Up @@ -14,25 +14,29 @@
begin
require "bootsnap"
rescue LoadError
raise if ENV["HOMEBREW_BOOTSNAP_RETRY"]
unless ENV["HOMEBREW_BOOTSNAP_RETRY"]
require "utils/gems"
Homebrew.install_bundler_gems!

require "utils/gems"
Homebrew.install_bundler_gems!

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

ENV.delete("HOMEBREW_BOOTSNAP_RETRY")

cache = ENV["HOMEBREW_CACHE"] || ENV["HOMEBREW_DEFAULT_CACHE"]
# Can't use .blank? here because we haven't required active_support yet.
raise "Needs HOMEBREW_CACHE or HOMEBREW_DEFAULT_CACHE!" if cache.nil? || cache.empty? # rubocop:disable Rails/Blank

Bootsnap.setup(
cache_dir: cache,
load_path_cache: true,
compile_cache_iseq: true,
compile_cache_yaml: true,
)
if defined?(Bootsnap)
cache = ENV["HOMEBREW_CACHE"] || ENV["HOMEBREW_DEFAULT_CACHE"]
# Can't use .blank? here because we haven't required active_support yet.
raise "Needs HOMEBREW_CACHE or HOMEBREW_DEFAULT_CACHE!" if cache.nil? || cache.empty? # rubocop:disable Rails/Blank

Bootsnap.setup(
cache_dir: cache,
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
end