brew/Library/Homebrew/homebrew_bootsnap.rb
Mike McQuaid dad1939142
Fix HOMEBREW_BOOTSNAP setup
- rename to `homebrew_bootsnap.rb` to avoid conflicting with the
  `bootsnap.rb` we need to `require`
- if the `require` fails: run bundler (until we vendor this gem)
2021-01-21 17:35:13 +00:00

35 lines
867 B
Ruby

# typed: ignore
# frozen_string_literal: true
# TODO: make this `typed: true` when HOMEBREW_BOOTSNAP is enabled by
# default and/or we vendor bootsnap and the RBI file.
raise "Needs HOMEBREW_BOOTSNAP!" unless ENV["HOMEBREW_BOOTSNAP"]
require "rubygems"
begin
require "bootsnap"
rescue LoadError
raise if ENV["HOMEBREW_BOOTSNAP_RETRY"]
Dir.chdir(HOMEBREW_LIBRARY_PATH) do
system "bundle", "install", "--standalone"
end
ENV["HOMEBREW_BOOTSNAP_RETRY"] = "1"
exec ENV["HOMEBREW_BREW_FILE"], *ARGV
end
ENV.delete("HOMEBREW_BOOTSNAP_RETRY")
Bootsnap.setup(
cache_dir: "#{ENV["HOMEBREW_TEMP"]}/homebrew-bootsnap",
development_mode: false, # TODO: use ENV["HOMEBREW_DEVELOPER"]?,
load_path_cache: true,
autoload_paths_cache: true,
disable_trace: true,
compile_cache_iseq: true,
compile_cache_yaml: true,
)