Skip to content

Commit

Permalink
Fix HOMEBREW_BOOTSNAP setup
Browse files Browse the repository at this point in the history
- 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)
  • Loading branch information
MikeMcQuaid committed Jan 21, 2021
1 parent f6bc3ef commit dad1939
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Library/.rubocop.yml
Expand Up @@ -370,7 +370,7 @@ Sorbet/FalseSigil:
- "/**/{Formula,Casks}/*.rb"
- "**/{Formula,Casks}/*.rb"
- "Homebrew/test/**/Casks/**/*.rb"
- "Homebrew/bootsnap.rb"
- "Homebrew/homebrew_bootsnap.rb"

Sorbet/StrictSigil:
Enabled: true
Expand Down
Expand Up @@ -7,7 +7,21 @@
raise "Needs HOMEBREW_BOOTSNAP!" unless ENV["HOMEBREW_BOOTSNAP"]

require "rubygems"
require "bootsnap"

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",
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/load_path.rb
Expand Up @@ -10,7 +10,7 @@
require "vendor/bundle/bundler/setup"

if ENV["HOMEBREW_BOOTSNAP"]
require "bootsnap"
require "homebrew_bootsnap"
else
$LOAD_PATH.select! { |d| Pathname(d).directory? }
$LOAD_PATH.uniq!
Expand Down

0 comments on commit dad1939

Please sign in to comment.