Uninstall Mac apps with every file they leave behind, and see why each belongs. Free up space, fine-tune macOS, and set up Terminal.
Swift cache-cleanercleanerclideveloper-toolsdisk-cleanupdisk-spaceduplicate-finderhomebrewliquid-glassmac-cleanermacosmacos-appmacos-golden-gatemacos-tahoemacos-tweaksswiftswiftuiterminal-themesuninstalluninstaller
Name the folder that kept Peel from telling which formulae to keep
Țugui Dragoș678372bc70fa
diff --git a/Localization/Peel/Localizable.xcstrings b/Localization/Peel/Localizable.xcstringsindex 974959d1..7ad71626 100644--- a/Localization/Peel/Localizable.xcstrings+++ b/Localization/Peel/Localizable.xcstrings@@ -140166,6 +140166,112 @@}}},+ "Peel couldn’t look inside %@ to tell which formulae your exclusions cover, so it ran nothing." : {+ "localizations" : {+ "cs" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel nemohl nahlédnout do složky %@, aby zjistil, na které formulae se vztahují vaše výjimky, a proto nic nespustil."+ }+ },+ "de" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel konnte nicht in %@ hineinsehen, um zu erkennen, welche Formulae unter deine Ausschlüsse fallen, und hat daher nichts ausgeführt."+ }+ },+ "es" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel no ha podido mirar dentro de %@ para saber qué formulae cubren tus exclusiones, así que no ha ejecutado nada."+ }+ },+ "fr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel n’a pas pu regarder dans %@ pour savoir quelles formulae sont concernées par vos exclusions : Peel n’a donc rien exécuté."+ }+ },+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel non è riuscito a esaminare %@ per capire quali sono le formulae coperte dalle tue esclusioni, quindi non ha eseguito nulla."+ }+ },+ "ja" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peelは、%@の中を調べられず、除外リストに含まれるformulaeを特定できなかったため、何も実行しませんでした。"+ }+ },+ "ko" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel은 제외 항목에 포함된 formulae를 확인하는 데 필요한 %@ 내부를 살펴볼 수 없어 아무것도 실행하지 않았습니다."+ }+ },+ "nl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel kon niet in %@ kijken om na te gaan welke formulae onder je uitsluitingen vallen, en heeft daarom niets uitgevoerd."+ }+ },+ "pl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel nie mógł zajrzeć do folderu %@, aby ustalić, które formulae są objęte Twoimi wykluczeniami, więc niczego nie uruchomił."+ }+ },+ "pt" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "O Peel não conseguiu examinar o conteúdo de %@ para identificar as formulae cobertas pelas suas exclusões, então não executou nada."+ }+ },+ "ro" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel nu a putut citi ce se află în %@ pentru a afla ce formule sunt acoperite de excluderile dvs., așa că nu a rulat nimic."+ }+ },+ "ru" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel не удалось заглянуть в папку %@, чтобы определить, на какие formulae распространяются Ваши исключения, поэтому ничего не было запущено."+ }+ },+ "sv" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel kunde inte titta inuti %@ för att avgöra vilka formulae som dina undantag omfattar, så Peel körde ingenting."+ }+ },+ "tr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel, hariç tutulanlarınızın kapsamında hangi formulae olduğunu anlamak için %@ klasörünün içine bakamadı, bu yüzden hiçbir şey çalıştırmadı."+ }+ },+ "uk" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel не вдалося зазирнути в папку %@, щоб визначити, які formulae є у ваших винятках, тож Peel нічого не запускала."+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel未能查看%@内部以判断哪些是你的排除项所涵盖的formulae,因此没有运行任何命令。"+ }+ },+ "zh-Hant" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel無法查看%@的內部以判斷哪些是你的排除項目所涵蓋的formulae,因此未執行任何Homebrew指令。"+ }+ }+ }+ },"Peel couldn’t look inside %@, so something may be there that isn’t listed here." : {"localizations" : {"cs" : {@@ -141438,112 +141544,6 @@}}},- "Peel couldn’t read Homebrew’s Cellar to tell which formulae your exclusions cover, so it ran nothing." : {- "localizations" : {- "cs" : {- "stringUnit" : {- "state" : "translated",- "value" : "Peel nemohl přečíst složku Cellar v Homebrew, aby zjistil, na které formulae se vztahují vaše výjimky, a proto nic nespustil."- }- },- "de" : {- "stringUnit" : {- "state" : "translated",- "value" : "Peel konnte den Cellar von Homebrew nicht lesen, um zu erkennen, welche Formulae unter deine Ausschlüsse fallen, und hat daher nichts ausgeführt."- }- },- "es" : {- "stringUnit" : {- "state" : "translated",- "value" : "Peel no ha podido leer el Cellar de Homebrew para saber qué formulae cubren tus exclusiones, así que no ha ejecutado nada."- }- },- "fr" : {- "stringUnit" : {- "state" : "translated",- "value" : "Peel n’a pas pu lire le dossier Cellar de Homebrew pour savoir quelles formulae sont concernées par vos exclusions : Peel n’a donc rien exécuté."- }- },- "it" : {- "stringUnit" : {- "state" : "translated",- "value" : "Peel non è riuscito a leggere la cartella Cellar di Homebrew per capire quali sono le formulae coperte dalle tue esclusioni, quindi non ha eseguito nulla."- }- },- "ja" : {- "stringUnit" : {- "state" : "translated",- "value" : "Peelは、HomebrewのCellarを読み取れず、除外リストに含まれるformulaeを特定できなかったため、何も実行しませんでした。"- }- },- "ko" : {- "stringUnit" : {- "state" : "translated",- "value" : "Peel은 제외 항목에 포함된 formulae를 확인하는 데 필요한 Homebrew의 Cellar를 읽을 수 없어 아무것도 실행하지 않았습니다."- }- },- "nl" : {- "stringUnit" : {- "state" : "translated",- "value" : "Peel kon de Cellar van Homebrew niet lezen om na te gaan welke formulae onder je uitsluitingen vallen, en heeft daarom niets uitgevoerd."- }- },- "pl" : {- "stringUnit" : {- "state" : "translated",- "value" : "Peel nie mógł odczytać folderu Cellar w Homebrew, aby ustalić, które formulae są objęte Twoimi wykluczeniami, więc niczego nie uruchomił."- }- },- "pt" : {- "stringUnit" : {- "state" : "translated",- "value" : "O Peel não conseguiu ler a pasta Cellar do Homebrew para identificar as formulae cobertas pelas suas exclusões, então não executou nada."- }- },- "ro" : {- "stringUnit" : {- "state" : "translated",- "value" : "Peel nu a putut citi dosarul Cellar al Homebrew pentru a afla ce formule sunt acoperite de excluderile dvs., așa că nu a rulat nimic."- }- },- "ru" : {- "stringUnit" : {- "state" : "translated",- "value" : "Peel не удалось прочитать папку Cellar Homebrew, чтобы определить, на какие formulae распространяются Ваши исключения, поэтому ничего не было запущено."- }- },- "sv" : {- "stringUnit" : {- "state" : "translated",- "value" : "Peel kunde inte läsa Homebrews Cellar för att avgöra vilka formulae som dina undantag omfattar, så Peel körde ingenting."- }- },- "tr" : {- "stringUnit" : {- "state" : "translated",- "value" : "Peel, hariç tutulanlarınızın kapsamında hangi formulae olduğunu anlamak için Homebrew’un Cellar klasörünü okuyamadı, bu yüzden hiçbir şey çalıştırmadı."- }- },- "uk" : {- "stringUnit" : {- "state" : "translated",- "value" : "Peel не вдалося прочитати папку Cellar Homebrew, щоб визначити, які formulae є у ваших винятках, тож Peel нічого не запускала."- }- },- "zh-Hans" : {- "stringUnit" : {- "state" : "translated",- "value" : "Peel未能读取Homebrew的Cellar以判断哪些是你的排除项所涵盖的formulae,因此没有运行任何命令。"- }- },- "zh-Hant" : {- "stringUnit" : {- "state" : "translated",- "value" : "Peel無法讀取Homebrew的Cellar以判斷哪些是你的排除項目所涵蓋的formulae,因此未執行任何Homebrew指令。"- }- }- }- },"Peel couldn’t read it in time to see whether it changed after Peel looked at it. Scan again to review it." : {"localizations" : {"cs" : {diff --git a/Packages/PeelCore/Sources/PeelCore/Support/Exclusions.swift b/Packages/PeelCore/Sources/PeelCore/Support/Exclusions.swiftindex 0596536d..8844cef5 100644--- a/Packages/PeelCore/Sources/PeelCore/Support/Exclusions.swift+++ b/Packages/PeelCore/Sources/PeelCore/Support/Exclusions.swift@@ -309,11 +309,11 @@ public struct Exclusions: Sendable, Codable, Hashable {/// The installed formulae whose own folder in `cellar` is excluded or holds something excluded, which Homebrew/// is told to keep: `brew cleanup`, and the autoremove `brew uninstall` runs, delete formulae and their old- /// versions for good. An unreadable list, or one not read yet, keeps every formula. Nil when the Cellar, or a- /// formula's folder in it, can't be looked into.- public func keptFormulae(inCellar cellar: URL) -> [String]? {+ /// versions for good. An unreadable list, or one not read yet, keeps every formula. Or the folder that can't be+ /// looked into: the Cellar, or a formula's own folder in it.+ public func keptFormulae(inCellar cellar: URL) -> Result<[String], CannotLookInside> {guard let names = ProtectedData.names(in: cellar.path(percentEncoded: false), followingLinks: true) else {- return nil+ return .failure(CannotLookInside(folder: cellar))}var kept: [String] = []for name in names.sorted() where !name.hasPrefix(".") {@@ -322,10 +322,15 @@ public struct Exclusions: Sendable, Codable, Hashable {kept.append(name)continue}- guard let holds = holdsSomething(own) else { return nil }+ guard let holds = holdsSomething(own) else { return .failure(CannotLookInside(folder: own)) }if holds { kept.append(name) }}- return kept+ return .success(kept)+ }++ /// A folder Peel can't look into, or into a folder a level or two inside it, for what the exclusions cover.+ public struct CannotLookInside: Error, Equatable {+ public let folder: URL}public func keeping<T>(_ items: [T], url: (T) -> URL) -> [T] {diff --git a/Packages/PeelCore/Tests/PeelCoreTests/HomebrewTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/HomebrewTests.swiftindex 4bea48e2..992a8cfa 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/HomebrewTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/HomebrewTests.swift@@ -357,12 +357,14 @@ struct HomebrewTests {try? directory.setPermissions(0o755, of: "Cellar/jq/1.8.1")}+ let cellar = directory.url.appending(path: "Cellar")try directory.setPermissions(0, of: "Cellar")- #expect(excludingWget.keptFormulae(inCellar: directory.url.appending(path: "Cellar")) == nil)+ #expect(excludingWget.keptFormulae(inCellar: cellar) == .failure(.init(folder: cellar)))try directory.setPermissions(0o755, of: "Cellar")try directory.setPermissions(0, of: "Cellar/jq/1.8.1")- #expect(excludingAnApp.keptFormulae(inCellar: directory.url.appending(path: "Cellar")) == nil)- #expect(excludingWget.keptFormulae(inCellar: directory.url.appending(path: "Missing/Cellar")) == [])+ let jq = cellar.appending(path: "jq", directoryHint: .isDirectory)+ #expect(excludingAnApp.keptFormulae(inCellar: cellar) == .failure(.init(folder: jq)))+ #expect(excludingWget.keptFormulae(inCellar: directory.url.appending(path: "Missing/Cellar")) == .success([]))}/// `brew cleanup` and the autoremove that `brew uninstall` runs delete formulae and their old versions for good,@@ -377,9 +379,9 @@ struct HomebrewTests {directory.url.appending(path: "Cellar/jq"), directory.url.appending(path: "Cellar/[email protected]/3.13.7"),])- let kept = try #require(exclusions.keptFormulae(inCellar: directory.url.appending(path: "Cellar")))+ let kept = try exclusions.keptFormulae(inCellar: directory.url.appending(path: "Cellar")).get()#expect(kept == ["jq", "[email protected]"])- #expect(Exclusions.unreadable.keptFormulae(inCellar: directory.url.appending(path: "Cellar")) == ["jq", "[email protected]", "wget"])+ #expect(Exclusions.unreadable.keptFormulae(inCellar: directory.url.appending(path: "Cellar")) == .success(["jq", "[email protected]", "wget"]))let attempt = try await Homebrew.execute(["-c", "printf %s \"$HOMEBREW_NO_CLEANUP_FORMULAE\""], autoUpdate: false, keeping: kept, timeout: 10,diff --git a/Peel/Model/HomebrewLibrary.swift b/Peel/Model/HomebrewLibrary.swiftindex 0b903135..304eccb6 100644--- a/Peel/Model/HomebrewLibrary.swift+++ b/Peel/Model/HomebrewLibrary.swift@@ -486,7 +486,8 @@ final class HomebrewLibrary {needsDefinitions = false// The other questions take about as long as each other, so they run at the same time. Only the page shows the// cleanup's figure.- let kept = found.flatMap { ExclusionsStore.shared.exclusions.keptFormulae(inCellar: $0.cellar) } ?? []+ let exclusions = ExclusionsStore.shared.exclusions+ let kept = found.flatMap { try? exclusions.keptFormulae(inCellar: $0.cellar).get() } ?? []async let preview = includingReclaimable ? Homebrew.cleanupPreview(asWrittenBy: found, keeping: kept) : nillet installed: Result<[HomebrewPackage], Homebrew.CommandFailure>var overridden: Homebrew.Overrides?@@ -659,7 +660,7 @@ final class HomebrewLibrary {/// The formulae the exclusions cover, read now, for a command the person runs in Terminal, or none when Peel/// can't tell which they are.var keptFormulaeNow: [String] {- installation.flatMap { ExclusionsStore.shared.exclusions.keptFormulae(inCellar: $0.cellar) } ?? []+ installation.flatMap { try? ExclusionsStore.shared.exclusions.keptFormulae(inCellar: $0.cellar).get() } ?? []}/// The formulae Homebrew is told to keep, or what Peel says when it runs nothing.@@ -672,8 +673,12 @@ final class HomebrewLibrary {/// deletes for good. Nothing runs when Peel can't tell which they are or Homebrew's own settings replace the list.private func keptFormulae() async -> Keeping {guard let cellar = installation?.cellar else { return .nothingRuns(keepsNothing) }- guard let kept = ExclusionsStore.shared.exclusions.keptFormulae(inCellar: cellar) else {- return .nothingRuns(CommandResult(succeeded: false, output: String(localized: "Peel couldn’t read Homebrew’s Cellar to tell which formulae your exclusions cover, so it ran nothing.")))+ let kept: [String]+ switch ExclusionsStore.shared.exclusions.keptFormulae(inCellar: cellar) {+ case .success(let names): kept = names+ case .failure(let closed):+ let folder = closed.folder.abbreviatedPath+ return .nothingRuns(CommandResult(succeeded: false, output: String(localized: "Peel couldn’t look inside \(folder) to tell which formulae your exclusions cover, so it ran nothing.")))}return await Homebrew.keepsEvery(kept) ? .formulae(kept) : .nothingRuns(keepsNothing)}