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
|
||||||
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.
|
# An array of all racks currently installed.
|
||||||
# @private
|
# @private
|
||||||
def self.racks
|
def self.racks
|
||||||
@racks ||= if HOMEBREW_CELLAR.directory?
|
Formula.cache[:racks] ||= if HOMEBREW_CELLAR.directory?
|
||||||
HOMEBREW_CELLAR.subdirs.reject do |rack|
|
HOMEBREW_CELLAR.subdirs.reject do |rack|
|
||||||
rack.symlink? || rack.basename.to_s.start_with?(".") || rack.subdirs.empty?
|
rack.symlink? || rack.basename.to_s.start_with?(".") || rack.subdirs.empty?
|
||||||
end
|
end
|
||||||
@ -1503,7 +1492,7 @@ class Formula
|
|||||||
# An array of all installed {Formula}
|
# An array of all installed {Formula}
|
||||||
# @private
|
# @private
|
||||||
def self.installed
|
def self.installed
|
||||||
@installed ||= racks.flat_map do |rack|
|
Formula.cache[:installed] ||= racks.flat_map do |rack|
|
||||||
Formulary.from_rack(rack)
|
Formulary.from_rack(rack)
|
||||||
rescue
|
rescue
|
||||||
[]
|
[]
|
||||||
|
@ -854,10 +854,11 @@ class FormulaInstaller
|
|||||||
end
|
end
|
||||||
|
|
||||||
def link(keg)
|
def link(keg)
|
||||||
|
Formula.clear_cache
|
||||||
|
|
||||||
unless link_keg
|
unless link_keg
|
||||||
begin
|
begin
|
||||||
keg.optlink(verbose: verbose?)
|
keg.optlink(verbose: verbose?)
|
||||||
Formula.clear_cache
|
|
||||||
rescue Keg::LinkError => e
|
rescue Keg::LinkError => e
|
||||||
onoe "Failed to create #{formula.opt_prefix}"
|
onoe "Failed to create #{formula.opt_prefix}"
|
||||||
puts "Things that depend on #{formula.full_name} will probably not build."
|
puts "Things that depend on #{formula.full_name} will probably not build."
|
||||||
|
@ -355,7 +355,7 @@ class Tab < OpenStruct
|
|||||||
def write
|
def write
|
||||||
# If this is a new installation, the cache of installed formulae
|
# If this is a new installation, the cache of installed formulae
|
||||||
# will no longer be valid.
|
# will no longer be valid.
|
||||||
Formula.clear_installed_formulae_cache unless tabfile.exist?
|
Formula.clear_cache unless tabfile.exist?
|
||||||
|
|
||||||
self.class.cache[tabfile] = self
|
self.class.cache[tabfile] = self
|
||||||
tabfile.atomic_write(to_json)
|
tabfile.atomic_write(to_json)
|
||||||
|
@ -36,7 +36,6 @@ describe Keg do
|
|||||||
end
|
end
|
||||||
|
|
||||||
specify "::all" do
|
specify "::all" do
|
||||||
Formula.clear_racks_cache
|
|
||||||
expect(described_class.all).to eq([keg])
|
expect(described_class.all).to eq([keg])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -128,6 +128,7 @@ module Homebrew
|
|||||||
.select do |f|
|
.select do |f|
|
||||||
keg = f.any_installed_keg
|
keg = f.any_installed_keg
|
||||||
next unless keg
|
next unless keg
|
||||||
|
next unless keg.directory?
|
||||||
|
|
||||||
LinkageChecker.new(keg, cache_db: db)
|
LinkageChecker.new(keg, cache_db: db)
|
||||||
.broken_library_linkage?
|
.broken_library_linkage?
|
||||||
@ -186,7 +187,7 @@ module Homebrew
|
|||||||
|
|
||||||
upgrade_formulae(upgradeable_dependents, args: args)
|
upgrade_formulae(upgradeable_dependents, args: args)
|
||||||
|
|
||||||
# Refresh installed formulae after upgrading
|
# Update installed formulae after upgrading
|
||||||
installed_formulae = FormulaInstaller.installed.to_a
|
installed_formulae = FormulaInstaller.installed.to_a
|
||||||
|
|
||||||
# Assess the dependents tree again now we've upgraded.
|
# Assess the dependents tree again now we've upgraded.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user