Invalidate Bootsnap cache on Gemfile.lock changes
This commit is contained in:
parent
0b3d78aa0f
commit
99ce3094e9
@ -278,6 +278,7 @@ Sorbet/StrictSigil:
|
|||||||
- "Taps/**/*"
|
- "Taps/**/*"
|
||||||
- "/**/{Formula,Casks}/**/*.rb"
|
- "/**/{Formula,Casks}/**/*.rb"
|
||||||
- "**/{Formula,Casks}/**/*.rb"
|
- "**/{Formula,Casks}/**/*.rb"
|
||||||
|
- "Homebrew/{standalone,startup}/*.rb" # These are loaded before sorbet-runtime
|
||||||
- "Homebrew/test/**/*.rb"
|
- "Homebrew/test/**/*.rb"
|
||||||
|
|
||||||
Sorbet/TrueSigil:
|
Sorbet/TrueSigil:
|
||||||
|
@ -295,6 +295,7 @@ module Homebrew
|
|||||||
|
|
||||||
cleanup_cache
|
cleanup_cache
|
||||||
cleanup_empty_api_source_directories
|
cleanup_empty_api_source_directories
|
||||||
|
cleanup_bootsnap
|
||||||
cleanup_logs
|
cleanup_logs
|
||||||
cleanup_lockfiles
|
cleanup_lockfiles
|
||||||
cleanup_python_site_packages
|
cleanup_python_site_packages
|
||||||
@ -314,7 +315,6 @@ module Homebrew
|
|||||||
return if periodic
|
return if periodic
|
||||||
|
|
||||||
cleanup_portable_ruby
|
cleanup_portable_ruby
|
||||||
cleanup_bootsnap
|
|
||||||
else
|
else
|
||||||
args.each do |arg|
|
args.each do |arg|
|
||||||
formula = begin
|
formula = begin
|
||||||
@ -528,9 +528,11 @@ module Homebrew
|
|||||||
|
|
||||||
def cleanup_bootsnap
|
def cleanup_bootsnap
|
||||||
bootsnap = cache/"bootsnap"
|
bootsnap = cache/"bootsnap"
|
||||||
return unless bootsnap.exist?
|
return unless bootsnap.directory?
|
||||||
|
|
||||||
cleanup_path(bootsnap) { bootsnap.rmtree }
|
bootsnap.each_child do |subdir|
|
||||||
|
cleanup_path(subdir) { subdir.rmtree } if subdir.basename.to_s != Homebrew.bootsnap_key
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def cleanup_cache_db(rack = nil)
|
def cleanup_cache_db(rack = nil)
|
||||||
|
@ -362,11 +362,4 @@ homebrew-vendor-install() {
|
|||||||
lock "vendor-install ${VENDOR_NAME}"
|
lock "vendor-install ${VENDOR_NAME}"
|
||||||
fetch
|
fetch
|
||||||
install
|
install
|
||||||
|
|
||||||
# Bootsnap needs cleaned up on a new Ruby version.
|
|
||||||
# It's cleaned up by every `brew cleanup` run anyway so not a big deal to do it here, too.
|
|
||||||
if [[ "${VENDOR_NAME}" == "ruby" ]]
|
|
||||||
then
|
|
||||||
rm -rf "${HOMEBREW_CACHE}/bootsnap"
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# typed: true # rubocop:disable Sorbet/StrictSigil
|
# typed: true
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# This file is included before any other files. It intentionally has typing disabled and has minimal use of `require`.
|
# This file is included before any other files. It intentionally has typing disabled and has minimal use of `require`.
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# typed: true # rubocop:todo Sorbet/StrictSigil
|
# typed: true
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "sorbet-runtime"
|
require "sorbet-runtime"
|
||||||
|
@ -1,16 +1,36 @@
|
|||||||
# typed: strict
|
# typed: true
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
homebrew_bootsnap_enabled = HOMEBREW_USING_PORTABLE_RUBY &&
|
homebrew_bootsnap_enabled = HOMEBREW_USING_PORTABLE_RUBY &&
|
||||||
ENV["HOMEBREW_NO_BOOTSNAP"].nil? &&
|
ENV["HOMEBREW_NO_BOOTSNAP"].nil? &&
|
||||||
!ENV["HOMEBREW_BOOTSNAP"].nil?
|
!ENV["HOMEBREW_BOOTSNAP"].nil?
|
||||||
|
|
||||||
|
module Homebrew
|
||||||
|
def self.bootsnap_key
|
||||||
|
@bootsnap_key ||= begin
|
||||||
|
require "digest/sha2"
|
||||||
|
|
||||||
|
checksum = Digest::SHA256.new
|
||||||
|
begin
|
||||||
|
checksum.file(HOMEBREW_LIBRARY_PATH/"Gemfile.lock")
|
||||||
|
rescue SystemCallError
|
||||||
|
# If it's inaccessible, let's just assume it's empty.
|
||||||
|
end
|
||||||
|
checksum << user_gem_groups.join(",")
|
||||||
|
|
||||||
|
"#{RUBY_VERSION}-#{checksum}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
if homebrew_bootsnap_enabled
|
if homebrew_bootsnap_enabled
|
||||||
require "bootsnap"
|
require "bootsnap"
|
||||||
|
|
||||||
cache = ENV.fetch("HOMEBREW_CACHE", nil) || ENV.fetch("HOMEBREW_DEFAULT_CACHE", nil)
|
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?
|
raise "Needs HOMEBREW_CACHE or HOMEBREW_DEFAULT_CACHE!" if cache.nil? || cache.empty?
|
||||||
|
|
||||||
|
cache = File.join(cache, "bootsnap", Homebrew.bootsnap_key)
|
||||||
|
|
||||||
# We never do `require "vendor/bundle/ruby/..."` or `require "vendor/portable-ruby/..."`,
|
# We never do `require "vendor/bundle/ruby/..."` or `require "vendor/portable-ruby/..."`,
|
||||||
# so let's slim the cache a bit by excluding them.
|
# 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.
|
# Note that gems within `bundle/ruby` will still be cached - these are when directory walking down from above.
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
# typed: strict
|
# typed: strict
|
||||||
|
|
||||||
|
module Homebrew
|
||||||
|
sig { returns(String) }
|
||||||
|
def self.bootsnap_key; end
|
||||||
|
end
|
||||||
|
|
||||||
module Bootsnap
|
module Bootsnap
|
||||||
sig {
|
sig {
|
||||||
params(
|
params(
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# typed: true # rubocop:todo Sorbet/StrictSigil
|
# typed: true
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
raise "HOMEBREW_BREW_FILE was not exported! Please call bin/brew directly!" unless ENV["HOMEBREW_BREW_FILE"]
|
raise "HOMEBREW_BREW_FILE was not exported! Please call bin/brew directly!" unless ENV["HOMEBREW_BREW_FILE"]
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# typed: true # rubocop:todo Sorbet/StrictSigil
|
# typed: true
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
RUBY_PATH = Pathname.new(RbConfig.ruby).freeze
|
RUBY_PATH = Pathname.new(RbConfig.ruby).freeze
|
||||||
|
Loading…
x
Reference in New Issue
Block a user