Fix upgrading dependents on missing keg
Ensure that we don't try to check for broken linkage in a keg that doesn't exist. Furthermore, fix the reason we checked for the keg that doesn't exist by `Formula.clear_cache`. While here, I noticed that there was other methods of caching at use in `Formula` so consolidate them to be consistent. Fixes #8997
This commit is contained in:
parent
771c961c5e
commit
ffe827ad0e
@ -1477,21 +1477,10 @@ class Formula
|
||||
end
|
||||
end
|
||||
|
||||
# Clear cache of .racks
|
||||
def self.clear_racks_cache
|
||||
@racks = nil
|
||||
end
|
||||
|
||||
# Clear caches of .racks and .installed.
|
||||
def self.clear_installed_formulae_cache
|
||||
clear_racks_cache
|
||||
@installed = nil
|
||||
end
|
||||
|
||||
# An array of all racks currently installed.
|
||||
# @private
|
||||
def self.racks
|
||||
@racks ||= if HOMEBREW_CELLAR.directory?
|
||||
Formula.cache[:racks] ||= if HOMEBREW_CELLAR.directory?
|
||||
HOMEBREW_CELLAR.subdirs.reject do |rack|
|
||||
rack.symlink? || rack.basename.to_s.start_with?(".") || rack.subdirs.empty?
|
||||
end
|
||||
@ -1503,7 +1492,7 @@ class Formula
|
||||
# An array of all installed {Formula}
|
||||
# @private
|
||||
def self.installed
|
||||
@installed ||= racks.flat_map do |rack|
|
||||
Formula.cache[:installed] ||= racks.flat_map do |rack|
|
||||
Formulary.from_rack(rack)
|
||||
rescue
|
||||
[]
|
||||
|
@ -854,10 +854,11 @@ class FormulaInstaller
|
||||
end
|
||||
|
||||
def link(keg)
|
||||
Formula.clear_cache
|
||||
|
||||
unless link_keg
|
||||
begin
|
||||
keg.optlink(verbose: verbose?)
|
||||
Formula.clear_cache
|
||||
rescue Keg::LinkError => e
|
||||
onoe "Failed to create #{formula.opt_prefix}"
|
||||
puts "Things that depend on #{formula.full_name} will probably not build."
|
||||
|
@ -355,7 +355,7 @@ class Tab < OpenStruct
|
||||
def write
|
||||
# If this is a new installation, the cache of installed formulae
|
||||
# will no longer be valid.
|
||||
Formula.clear_installed_formulae_cache unless tabfile.exist?
|
||||
Formula.clear_cache unless tabfile.exist?
|
||||
|
||||
self.class.cache[tabfile] = self
|
||||
tabfile.atomic_write(to_json)
|
||||
|
@ -36,7 +36,6 @@ describe Keg do
|
||||
end
|
||||
|
||||
specify "::all" do
|
||||
Formula.clear_racks_cache
|
||||
expect(described_class.all).to eq([keg])
|
||||
end
|
||||
|
||||
|
@ -128,6 +128,7 @@ module Homebrew
|
||||
.select do |f|
|
||||
keg = f.any_installed_keg
|
||||
next unless keg
|
||||
next unless keg.directory?
|
||||
|
||||
LinkageChecker.new(keg, cache_db: db)
|
||||
.broken_library_linkage?
|
||||
@ -186,7 +187,7 @@ module Homebrew
|
||||
|
||||
upgrade_formulae(upgradeable_dependents, args: args)
|
||||
|
||||
# Refresh installed formulae after upgrading
|
||||
# Update installed formulae after upgrading
|
||||
installed_formulae = FormulaInstaller.installed.to_a
|
||||
|
||||
# Assess the dependents tree again now we've upgraded.
|
||||
|
Loading…
x
Reference in New Issue
Block a user