Skip to content

armgit / peel

Public Imported from GitHub
0

Uninstall Mac apps with every file they leave behind, and see why each belongs. Free up space, fine-tune macOS, and set up Terminal.

Run a brew where Homebrew installs itself only by the chosen one's rule

Țugui Dragoș098354e63b49
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4c52d104..d2241cc2 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -32,8 +32,9 @@ its changes the way [Keep a Changelog](https://keepachangelog.com/) suggests.
Open or Stop and Quit.
- A cask whose upgrade was stopped, its app left in Homebrew's folder, says so on its page, with the command that
reinstalls it to copy.
-- When Homebrew belongs to another account of the Mac, the page says so and changes nothing: what only reads, such as
- the lists, Check Health, and the vulnerability scan, stays.
+- When Homebrew belongs to another account of the Mac, the page says so and Peel doesn't run its `brew`, which that
+ account could change. One this account can only read, such as one root owns, keeps the lists, Check Health, and
+ the vulnerability scan.
#### File Search
diff --git a/Localization/Peel/Localizable.xcstrings b/Localization/Peel/Localizable.xcstrings
index e1a14d54..8cbd469e 100644
--- a/Localization/Peel/Localizable.xcstrings
+++ b/Localization/Peel/Localizable.xcstrings
@@ -59046,6 +59046,113 @@
}
}
},
+ "Homebrew’s `brew` is in %@, and Peel doesn’t run it." : {
+ "comment" : "On the Homebrew page when the brew program where Homebrew installs itself belongs to another account of the Mac, or anyone can change it. %@ is its path, such as /opt/homebrew/bin/brew. A line under it says why. Keep `brew` as it is.",
+ "localizations" : {
+ "cs" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Homebrew má svůj `brew` v umístění %@ a Peel ho nespouští."
+ }
+ },
+ "de" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Das `brew` von Homebrew liegt in %@, und Peel führt es nicht aus."
+ }
+ },
+ "es" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "El `brew` de Homebrew está en %@, y Peel no lo ejecuta."
+ }
+ },
+ "fr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Le `brew` de Homebrew se trouve dans %@, et Peel ne l’exécute pas."
+ }
+ },
+ "it" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Il `brew` di Homebrew si trova in %@, e Peel non lo esegue."
+ }
+ },
+ "ja" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Homebrewの`brew`は%@にありますが、Peelはこれを実行しません。"
+ }
+ },
+ "ko" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Homebrew의 `brew`는 %@에 있으며, Peel은 이를 실행하지 않습니다."
+ }
+ },
+ "nl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "De `brew` van Homebrew staat op %@, en Peel voert die niet uit."
+ }
+ },
+ "pl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Homebrew ma swój plik `brew` w %@, a Peel go nie uruchamia."
+ }
+ },
+ "pt" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "O `brew` do Homebrew está em %@, e o Peel não o executa."
+ }
+ },
+ "ro" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Programul `brew` al Homebrew se află în %@, iar Peel nu îl rulează."
+ }
+ },
+ "ru" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Файл `brew` этого Homebrew находится в %@, и Peel его не запускает."
+ }
+ },
+ "sv" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Homebrews `brew` finns i %@, och Peel kör den inte."
+ }
+ },
+ "tr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Homebrew’un `brew` programı %@ konumunda ve Peel onu çalıştırmaz."
+ }
+ },
+ "uk" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "`brew` цього Homebrew розташовано за шляхом %@, і Peel його не запускає."
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Homebrew的`brew`位于%@,Peel不会运行它。"
+ }
+ },
+ "zh-Hant" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Homebrew的`brew`位於%@,Peel不會執行它。"
+ }
+ }
+ }
+ },
"Homebrew’s own housekeeping, run by Homebrew. Peel adds nothing of its own." : {
"localizations" : {
"cs" : {
@@ -115417,6 +115524,113 @@
}
}
},
+ "Peel Doesn’t Run This Homebrew" : {
+ "comment" : "The title of the Homebrew page when Peel won't run the Homebrew it found, because another account owns it or anyone on the Mac can change it.",
+ "localizations" : {
+ "cs" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel tento Homebrew nespouští"
+ }
+ },
+ "de" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel führt dieses Homebrew nicht aus"
+ }
+ },
+ "es" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel no ejecuta este Homebrew"
+ }
+ },
+ "fr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel n’exécute pas ce Homebrew"
+ }
+ },
+ "it" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel non esegue questo Homebrew"
+ }
+ },
+ "ja" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "PeelはこのHomebrewを実行しません"
+ }
+ },
+ "ko" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel이 이 Homebrew를 실행하지 않음"
+ }
+ },
+ "nl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel voert deze Homebrew niet uit"
+ }
+ },
+ "pl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel nie uruchamia tego Homebrew"
+ }
+ },
+ "pt" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "O Peel Não Executa Este Homebrew"
+ }
+ },
+ "ro" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel nu rulează această instalare Homebrew"
+ }
+ },
+ "ru" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel не запускает этот Homebrew"
+ }
+ },
+ "sv" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel kör inte det här Homebrew"
+ }
+ },
+ "tr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel Bu Homebrew’u Çalıştırmaz"
+ }
+ },
+ "uk" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel не запускає цей Homebrew"
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel不会运行此Homebrew"
+ }
+ },
+ "zh-Hant" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel不會執行此Homebrew"
+ }
+ }
+ }
+ },
"Peel Inventory.%@" : {
"comment" : "A suggested file name. Translate the words before the dot. %@ is the file extension, such as json.",
"localizations" : {
@@ -122670,6 +122884,113 @@
}
}
},
+ "Peel doesn’t run this `brew`." : {
+ "comment" : "In Settings > General > Homebrew and on the Terminal page's Tools tab, beside the path of a brew program Peel won't run. A line under it says why. Keep `brew` as it is.",
+ "localizations" : {
+ "cs" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Tento `brew` Peel nespouští."
+ }
+ },
+ "de" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel führt dieses `brew` nicht aus."
+ }
+ },
+ "es" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel no ejecuta este `brew`."
+ }
+ },
+ "fr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel n’exécute pas ce `brew`."
+ }
+ },
+ "it" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel non esegue questo `brew`."
+ }
+ },
+ "ja" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peelはこの`brew`を実行しません。"
+ }
+ },
+ "ko" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel은 이 `brew`를 실행하지 않습니다."
+ }
+ },
+ "nl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel voert deze `brew` niet uit."
+ }
+ },
+ "pl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel nie uruchamia tego `brew`."
+ }
+ },
+ "pt" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "O Peel não executa este `brew`."
+ }
+ },
+ "ro" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel nu rulează acest program `brew`."
+ }
+ },
+ "ru" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel не запускает этот `brew`."
+ }
+ },
+ "sv" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel kör inte den här `brew`."
+ }
+ },
+ "tr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel bu `brew` programını çalıştırmaz."
+ }
+ },
+ "uk" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel не запускає цей `brew`."
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel不会运行此`brew`。"
+ }
+ },
+ "zh-Hant" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel不會執行此`brew`。"
+ }
+ }
+ }
+ },
"Peel doesn’t turn extensions on or off: macOS does. Removing one means removing the app it came with." : {
"localizations" : {
"cs" : {
diff --git a/Packages/PeelCore/Sources/PeelCommandLine/Commands/AppCommands.swift b/Packages/PeelCore/Sources/PeelCommandLine/Commands/AppCommands.swift
index b5b05231..fbeef166 100644
--- a/Packages/PeelCore/Sources/PeelCommandLine/Commands/AppCommands.swift
+++ b/Packages/PeelCore/Sources/PeelCommandLine/Commands/AppCommands.swift
@@ -51,7 +51,10 @@ struct InventoryCommand: AsyncParsableCommand {
private static func brewfile() async throws -> String {
let why: String
if !(await Homebrew.hasLocalDefinitions()) {
- why = noDefinitions(isInstalled: Homebrew.executableURL != nil, unrunnable: HomebrewChoice().unrunnable())
+ why = noDefinitions(
+ isInstalled: Homebrew.executableURL != nil, unrunnable: HomebrewChoice().unrunnable(),
+ refused: Homebrew.refusedInAUsualPlace()
+ )
} else if let installation = await Homebrew.installation() {
do {
return try await Homebrew.brewfile(from: installation)
@@ -75,10 +78,13 @@ struct InventoryCommand: AsyncParsableCommand {
why = error.output
}
} else {
- why = noDefinitions(isInstalled: Homebrew.executableURL != nil, unrunnable: HomebrewChoice().unrunnable())
+ why = noDefinitions(
+ isInstalled: Homebrew.executableURL != nil, unrunnable: HomebrewChoice().unrunnable(),
+ refused: Homebrew.refusedInAUsualPlace()
+ )
}
- let isChosen = HomebrewChoice().load() != nil
- if let note = homebrewNote(isInstalled: Homebrew.executableURL != nil || isChosen, why: why) {
+ let isThere = HomebrewChoice().load() != nil || Homebrew.refusedInAUsualPlace() != nil
+ if let note = homebrewNote(isInstalled: Homebrew.executableURL != nil || isThere, why: why) {
Output.note(note)
}
return []
@@ -92,10 +98,16 @@ struct InventoryCommand: AsyncParsableCommand {
/// Why Homebrew was not asked: without its local copy of the definitions it would download them. The copy is
/// missing because Homebrew isn't installed, or because it never fetched one.
- static func noDefinitions(isInstalled: Bool, unrunnable: HomebrewChoice.Unrunnable? = nil) -> String {
+ static func noDefinitions(
+ isInstalled: Bool, unrunnable: HomebrewChoice.Unrunnable? = nil, refused: HomebrewChoice.Unrunnable? = nil
+ ) -> String {
if let unrunnable {
return "Peel runs only the brew chosen in its Settings, \(unrunnable.brew.path(percentEncoded: false)), and that one can't be run."
}
+ if let refused {
+ let owner = refused.refusal == .ownedByAnotherAccount ? "another account owns it" : "anyone on this Mac can change it"
+ return "Peel doesn't run the brew in \(refused.brew.path(percentEncoded: false)): \(owner)."
+ }
return isInstalled ? "Homebrew has no list of packages on this Mac. Run `brew update` first." : "Homebrew isn't installed."
}
}
diff --git a/Packages/PeelCore/Sources/PeelCore/Homebrew/Homebrew.swift b/Packages/PeelCore/Sources/PeelCore/Homebrew/Homebrew.swift
index 43bc55cd..4e43ff87 100644
--- a/Packages/PeelCore/Sources/PeelCore/Homebrew/Homebrew.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Homebrew/Homebrew.swift
@@ -549,11 +549,31 @@ public enum Homebrew {
executable(chosen: HomebrewChoice().load())
}
- static func executable(chosen: URL?) -> URL? {
- if let chosen { return HomebrewChoice.refusal(of: chosen) == nil ? chosen : nil }
- return ["/opt/homebrew/bin/brew", "/usr/local/bin/brew"]
- .map { URL(filePath: $0) }
- .first { FileManager.default.isExecutableFile(atPath: $0.path(percentEncoded: false)) }
+ static let usualPlaces = ["/opt/homebrew/bin/brew", "/usr/local/bin/brew"].map { URL(filePath: $0) }
+
+ /// A `brew` in a usual place runs by the rule a chosen one does: this account's or root's, and nobody else can
+ /// change it, since its code runs as this account whenever Peel asks Homebrew something.
+ static func executable(chosen: URL?, usualPlaces: [URL] = Homebrew.usualPlaces, user: uid_t = getuid()) -> URL? {
+ if let chosen { return HomebrewChoice.refusal(of: chosen, user: user) == nil ? chosen : nil }
+ return usualPlaces.first { HomebrewChoice.refusal(of: $0, user: user) == nil }
+ }
+
+ /// The `brew` in a usual place that Peel won't run, and why, when none was chosen and none there can run.
+ public static func refusedInAUsualPlace() -> HomebrewChoice.Unrunnable? {
+ refusedInAUsualPlace(chosen: HomebrewChoice().load(), usualPlaces: usualPlaces)
+ }
+
+ static func refusedInAUsualPlace(
+ chosen: URL?, usualPlaces: [URL], user: uid_t = getuid()
+ ) -> HomebrewChoice.Unrunnable? {
+ guard chosen == nil, executable(chosen: nil, usualPlaces: usualPlaces, user: user) == nil else { return nil }
+ return usualPlaces.lazy.compactMap { brew in
+ switch HomebrewChoice.refusal(of: brew, user: user) {
+ case let refusal? where refusal == .ownedByAnotherAccount || refusal == .writableByEveryone:
+ HomebrewChoice.Unrunnable(brew: brew, refusal: refusal)
+ default: nil
+ }
+ }.first
}
/// Returns whether Homebrew's local copy of its definitions is on disk. Without it, any command that may read
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/CommandLineTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/CommandLineTests.swift
index 463c825d..4811c5f1 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/CommandLineTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/CommandLineTests.swift
@@ -13,6 +13,8 @@ struct CommandLineTests {
#expect(InventoryCommand.noDefinitions(isInstalled: true) == "Homebrew has no list of packages on this Mac. Run `brew update` first.")
let chosen = HomebrewChoice.Unrunnable(brew: URL(filePath: "/opt/brew/bin/brew"), refusal: .notAProgram)
#expect(InventoryCommand.noDefinitions(isInstalled: false, unrunnable: chosen) == "Peel runs only the brew chosen in its Settings, /opt/brew/bin/brew, and that one can't be run.")
+ let theirs = HomebrewChoice.Unrunnable(brew: URL(filePath: "/opt/homebrew/bin/brew"), refusal: .ownedByAnotherAccount)
+ #expect(InventoryCommand.noDefinitions(isInstalled: false, refused: theirs) == "Peel doesn't run the brew in /opt/homebrew/bin/brew: another account owns it.")
}
/// A list of apps says nothing of Homebrew on a Mac without it, and says why when Homebrew is there and did
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/HomebrewChoiceTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/HomebrewChoiceTests.swift
index 9a16c9d2..191ad31d 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/HomebrewChoiceTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/HomebrewChoiceTests.swift
@@ -49,6 +49,20 @@ struct HomebrewChoiceTests {
#expect(Homebrew.executable(chosen: choice.load()) == nil)
}
+ @Test func runsABrewInAUsualPlaceOnlyByTheRuleAChosenOneFollows() throws {
+ let directory = try TemporaryDirectory()
+ let brew = try program("opt/homebrew/bin/brew", in: directory)
+ let missing = directory.url.appending(path: "usr/local/bin/brew")
+
+ #expect(Homebrew.executable(chosen: nil, usualPlaces: [missing, brew]) == brew)
+ #expect(Homebrew.refusedInAUsualPlace(chosen: nil, usualPlaces: [missing, brew]) == nil)
+
+ #expect(Homebrew.executable(chosen: nil, usualPlaces: [missing, brew], user: getuid() + 1) == nil)
+ let refused = Homebrew.refusedInAUsualPlace(chosen: nil, usualPlaces: [missing, brew], user: getuid() + 1)
+ #expect(refused == HomebrewChoice.Unrunnable(brew: brew, refusal: .ownedByAnotherAccount))
+ #expect(Homebrew.refusedInAUsualPlace(chosen: brew, usualPlaces: [missing, brew], user: getuid() + 1) == nil)
+ }
+
@Test func runsTheChosenBrewAndFindsItsOwnPrograms() throws {
let directory = try TemporaryDirectory()
let brew = try program("opt/brew/bin/brew", in: directory)
diff --git a/Peel/Model/HomebrewLibrary.swift b/Peel/Model/HomebrewLibrary.swift
index 4cfe127b..1f8573b0 100644
--- a/Peel/Model/HomebrewLibrary.swift
+++ b/Peel/Model/HomebrewLibrary.swift
@@ -63,6 +63,8 @@ final class HomebrewLibrary {
private(set) var isInstalled = Homebrew.executableURL != nil
/// The `brew` chosen in Settings when it can no longer be run, in which case Peel runs none.
private(set) var unrunnableChoice = HomebrewChoice().unrunnable()
+ /// A `brew` where Homebrew installs itself that another account owns or anyone can change, which Peel doesn't run.
+ private(set) var refusedBrew = Homebrew.refusedInAUsualPlace()
/// Homebrew's output when the last reading failed, which is not the same as nothing being installed.
private(set) var couldNotRead: String?
private(set) var packages: [HomebrewPackage]?
@@ -212,12 +214,13 @@ final class HomebrewLibrary {
func checkInstalled() {
isInstalled = Homebrew.executableURL != nil
unrunnableChoice = HomebrewChoice().unrunnable()
+ refusedBrew = Homebrew.refusedInAUsualPlace()
}
- /// Whether the sidebar shows the Homebrew page by default: also while the `brew` chosen can't be run, so the page
- /// can say so.
- var isInstalledOrChosen: Bool {
- isInstalled || unrunnableChoice != nil
+ /// Whether the sidebar shows the Homebrew page by default: also while Peel won't run the `brew` it found, so the
+ /// page can say why.
+ var isOnThisMac: Bool {
+ isInstalled || unrunnableChoice != nil || refusedBrew != nil
}
/// Reads the packages again when Homebrew checked for new versions since they were read, as `brew update` in
@@ -235,6 +238,7 @@ final class HomebrewLibrary {
func refresh(includingReclaimable: Bool = false) async {
isInstalled = Homebrew.executableURL != nil
unrunnableChoice = HomebrewChoice().unrunnable()
+ refusedBrew = Homebrew.refusedInAUsualPlace()
guard isInstalled else {
forgetHomebrew()
return
diff --git a/Peel/Model/TerminalToolLibrary.swift b/Peel/Model/TerminalToolLibrary.swift
index 1d359e39..52f8e5df 100644
--- a/Peel/Model/TerminalToolLibrary.swift
+++ b/Peel/Model/TerminalToolLibrary.swift
@@ -8,6 +8,7 @@ final class TerminalToolLibrary {
var prefix: URL?
var installed: Set<TerminalTool>
var unrunnable: HomebrewChoice.Unrunnable?
+ var refused: HomebrewChoice.Unrunnable?
}
struct Catalog {
@@ -30,7 +31,10 @@ final class TerminalToolLibrary {
func refresh() async {
let prefix = Homebrew.executableURL?.deletingLastPathComponent().deletingLastPathComponent()
let installed = prefix.map { prefix in TerminalTool.allCases.filter { $0.isInstalled(prefix: prefix) } } ?? []
- state = State(prefix: prefix, installed: Set(installed), unrunnable: HomebrewChoice().unrunnable())
+ state = State(
+ prefix: prefix, installed: Set(installed), unrunnable: HomebrewChoice().unrunnable(),
+ refused: Homebrew.refusedInAUsualPlace()
+ )
guard prefix != nil else { return }
if case .notAsked = asked {
asked = .asking
diff --git a/Peel/Views/Homebrew/HomebrewList.swift b/Peel/Views/Homebrew/HomebrewList.swift
index c2a9e5ad..770a4c15 100644
--- a/Peel/Views/Homebrew/HomebrewList.swift
+++ b/Peel/Views/Homebrew/HomebrewList.swift
@@ -74,6 +74,7 @@ struct HomebrewList: View {
homebrew.isScanning,
found: homebrew.summary,
couldNotLook: homebrew.unrunnableChoice != nil ? "Peel Can’t Run the `brew` You Chose"
+ : homebrew.refusedBrew != nil ? "Peel Doesn’t Run This Homebrew"
: !homebrew.isInstalled ? "Homebrew Isn’t Installed"
: !homebrew.needsDefinitions ? nil
: homebrew.mayChange ? "Homebrew Has to Update First" : "Homebrew Belongs to Another Account",
@@ -703,6 +704,17 @@ struct HomebrewList: View {
} actions: {
Button("Open Peel Settings") { SettingsPane.general.open(with: openSettings) }
}
+ } else if let refused = homebrew.refusedBrew {
+ ContentUnavailableView {
+ Label("Peel Doesn’t Run This Homebrew", systemImage: "mug")
+ } description: {
+ VStack(spacing: 6) {
+ Text("Homebrew’s `brew` is in \(refused.brew.abbreviatedPath), and Peel doesn’t run it.")
+ refused.refusal.explanation
+ }
+ } actions: {
+ Button("Homebrew Is in Another Folder") { SettingsPane.general.open(with: openSettings) }
+ }
} else if !homebrew.isInstalled {
ContentUnavailableView {
Label("Homebrew Isn’t Installed", systemImage: "mug")
diff --git a/Peel/Views/MenuBarFound.swift b/Peel/Views/MenuBarFound.swift
index a570f3f0..3f68cfc8 100644
--- a/Peel/Views/MenuBarFound.swift
+++ b/Peel/Views/MenuBarFound.swift
@@ -45,7 +45,7 @@ struct MenuBarFound: View {
private var lines: [Line] {
let hidden = Tool.hidden(
- by: SidebarChoices(stored: sidebarTools), homebrewIsInstalled: homebrew.isInstalledOrChosen
+ by: SidebarChoices(stored: sidebarTools), homebrewIsInstalled: homebrew.isOnThisMac
)
return store.findings.compactMap { tool, finding in
let looked = Looked(count: finding.count, size: finding.size)
diff --git a/Peel/Views/Settings/HomebrewSection.swift b/Peel/Views/Settings/HomebrewSection.swift
index d351e150..f92c5930 100644
--- a/Peel/Views/Settings/HomebrewSection.swift
+++ b/Peel/Views/Settings/HomebrewSection.swift
@@ -14,9 +14,11 @@ struct HomebrewSection: View {
var body: some View {
let unrunnable = HomebrewChoice().unrunnable()
+ let refused = Homebrew.refusedInAUsualPlace()
+ let brew = unrunnable?.brew ?? refused?.brew ?? Homebrew.executableURL
Section {
LabeledContent {
- Text((unrunnable?.brew ?? Homebrew.executableURL)?.abbreviatedPath ?? String(localized: "Not found"))
+ Text(brew?.abbreviatedPath ?? String(localized: "Not found"))
.lineLimit(1)
.truncationMode(.middle)
} label: {
@@ -29,6 +31,13 @@ struct HomebrewSection: View {
.font(.callout)
.foregroundStyle(.secondary)
}
+ } else if let refused {
+ VStack(alignment: .leading, spacing: 4) {
+ StatusLabel(title: Text("Peel doesn’t run this `brew`."))
+ refused.refusal.explanation
+ .font(.callout)
+ .foregroundStyle(.secondary)
+ }
}
if couldNotSave {
StatusLabel(title: Text("Peel couldn’t save which `brew` to run."))
diff --git a/Peel/Views/Settings/SettingsView.swift b/Peel/Views/Settings/SettingsView.swift
index eda902c9..3908fb62 100644
--- a/Peel/Views/Settings/SettingsView.swift
+++ b/Peel/Views/Settings/SettingsView.swift
@@ -606,7 +606,7 @@ extension GeneralSettingsView {
extension GeneralSettingsView {
private var sidebarToolsSummary: String {
let hidden = Tool.hidden(
- by: SidebarChoices(stored: sidebarTools), homebrewIsInstalled: homebrew.isInstalledOrChosen
+ by: SidebarChoices(stored: sidebarTools), homebrewIsInstalled: homebrew.isOnThisMac
)
let left = Tool.Group.allCases.flatMap(\.tools).filter(hidden.contains).map { String(localized: $0.title) }
guard !left.isEmpty else { return String(localized: "Every tool is in the sidebar.") }
@@ -630,7 +630,7 @@ extension GeneralSettingsView {
Binding(
get: {
!Tool.hidden(
- by: SidebarChoices(stored: sidebarTools), homebrewIsInstalled: homebrew.isInstalledOrChosen
+ by: SidebarChoices(stored: sidebarTools), homebrewIsInstalled: homebrew.isOnThisMac
).contains(tool)
},
set: { shows in
diff --git a/Peel/Views/Terminal/ToolsTab.swift b/Peel/Views/Terminal/ToolsTab.swift
index 9135b8ba..2852c7a8 100644
--- a/Peel/Views/Terminal/ToolsTab.swift
+++ b/Peel/Views/Terminal/ToolsTab.swift
@@ -17,6 +17,18 @@ struct ToolsTab: View {
}
.padding(.vertical, 4)
}
+ } else if let refused = state.refused {
+ Section {
+ VStack(alignment: .leading, spacing: 4) {
+ StatusLabel(title: Text("Peel doesn’t run this `brew`."))
+ Text(refused.brew.abbreviatedPath)
+ .font(.caption.monospaced())
+ refused.refusal.explanation
+ .font(.callout)
+ .foregroundStyle(.secondary)
+ }
+ .padding(.vertical, 4)
+ }
} else if state.prefix == nil {
Section {
VStack(alignment: .leading, spacing: 4) {