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 the Homebrew in /usr/local through Rosetta on Apple silicon, and say so

Țugui Dragoș30beacaa4344
diff --git a/GUIDE.md b/GUIDE.md
index cdae8b2f..0acab174 100644
--- a/GUIDE.md
+++ b/GUIDE.md
@@ -287,8 +287,10 @@ and how many items the others hold.
Upgrade stays off for a package you excluded, since an upgrade deletes the version it replaces. Homebrew
replaces or deletes a cask's app even while it runs, so Peel asks the app to quit first, and opens it again after an
upgrade. It deletes a formula from under what runs from it too, and leaves its `brew services` job behind, so the
- question before Uninstall names what uses the formula and the command that stops the job. A cask Homebrew still lists though its app isn't where Homebrew put it anymore, or, for a cask with no app,
- its packages are gone, can't be upgraded. It is listed apart under Apps Already Gone, where Forget Cask, or Forget
+ question before Uninstall names what uses the formula and the command that stops the job. On a Mac with Apple
+ silicon, a Homebrew in `/usr/local` is an Intel one, so Peel runs it through Rosetta and the page says so. A cask
+ Homebrew still lists though its app isn't where Homebrew put it anymore, or, for a cask with no app, its packages
+ are gone, can't be upgraded. It is listed apart under Apps Already Gone, where Forget Cask, or Forget
All for every one of them, moves Homebrew's record of it to the Trash, with the links Homebrew made into it in its
command and completion folders, so Homebrew stops listing it, and History can put it back. Peel runs Homebrew
without your shell's settings, so Homebrew reads its own from `~/.homebrew/brew.env` there: a proxy you want it to
diff --git a/Localization/Peel/Localizable.xcstrings b/Localization/Peel/Localizable.xcstrings
index 3efc0389..89bed3bb 100644
--- a/Localization/Peel/Localizable.xcstrings
+++ b/Localization/Peel/Localizable.xcstrings
@@ -23583,6 +23583,112 @@
}
}
},
+ "Built For" : {
+ "localizations" : {
+ "cs" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Určeno pro"
+ }
+ },
+ "de" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Entwickelt für"
+ }
+ },
+ "es" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Creado para"
+ }
+ },
+ "fr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Conçu pour"
+ }
+ },
+ "it" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Compilato per"
+ }
+ },
+ "ja" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "対応プロセッサ"
+ }
+ },
+ "ko" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "빌드 대상"
+ }
+ },
+ "nl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Gemaakt voor"
+ }
+ },
+ "pl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Skompilowano dla"
+ }
+ },
+ "pt" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Feito para"
+ }
+ },
+ "ro" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Compilat pentru"
+ }
+ },
+ "ru" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Собран для"
+ }
+ },
+ "sv" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Byggt för"
+ }
+ },
+ "tr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Derlendiği İşlemci"
+ }
+ },
+ "uk" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Створено для"
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "构建目标"
+ }
+ },
+ "zh-Hant" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "建置平台"
+ }
+ }
+ }
+ },
"Built for Intel processors only. On Apple silicon it needs Rosetta." : {
"localizations" : {
"cs" : {
@@ -68864,6 +68970,218 @@
}
}
},
+ "Intel. Peel runs it through Rosetta." : {
+ "localizations" : {
+ "cs" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Intel. Peel ho spouští v prostředí Rosetta."
+ }
+ },
+ "de" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Intel. Peel führt es mit Rosetta aus."
+ }
+ },
+ "es" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Intel. Peel lo ejecuta mediante Rosetta."
+ }
+ },
+ "fr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Intel. Peel l’exécute grâce à Rosetta."
+ }
+ },
+ "it" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Intel. Peel lo esegue tramite Rosetta."
+ }
+ },
+ "ja" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Intel。PeelはRosetta経由で実行します。"
+ }
+ },
+ "ko" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Intel. Peel은 Rosetta를 통해 실행합니다."
+ }
+ },
+ "nl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Intel. Peel voert het uit via Rosetta."
+ }
+ },
+ "pl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Intel. Peel uruchamia go za pomocą Rosetty."
+ }
+ },
+ "pt" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Intel. O Peel o executa pelo Rosetta."
+ }
+ },
+ "ro" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Intel. Peel îl rulează prin Rosetta."
+ }
+ },
+ "ru" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Intel. Peel запускает его через Rosetta."
+ }
+ },
+ "sv" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Intel. Peel kör det via Rosetta."
+ }
+ },
+ "tr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Intel. Peel onu Rosetta ile çalıştırır."
+ }
+ },
+ "uk" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Intel. Peel запускає його через Rosetta."
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Intel。Peel通过Rosetta运行它。"
+ }
+ },
+ "zh-Hant" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Intel。Peel會透過Rosetta執行它。"
+ }
+ }
+ }
+ },
+ "Intel. Rosetta isn’t installed, so it can’t run." : {
+ "localizations" : {
+ "cs" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Intel. Prostředí Rosetta není nainstalované, takže balíček nemůže běžet."
+ }
+ },
+ "de" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Intel. Rosetta ist nicht installiert, daher kann es nicht laufen."
+ }
+ },
+ "es" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Intel. Rosetta no se ha instalado, así que no puede ejecutarse."
+ }
+ },
+ "fr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Intel. Rosetta n’est pas installé : Homebrew ne peut donc pas s’exécuter."
+ }
+ },
+ "it" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Intel. Rosetta non è installato, quindi non può funzionare."
+ }
+ },
+ "ja" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Intel。Rosettaがインストールされていないため、実行できません。"
+ }
+ },
+ "ko" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Intel. Rosetta가 설치되어 있지 않으므로 실행할 수 없습니다."
+ }
+ },
+ "nl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Intel. Rosetta is niet geïnstalleerd, dus het kan niet worden uitgevoerd."
+ }
+ },
+ "pl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Intel. Rosetta nie jest zainstalowana, więc Homebrew nie może działać."
+ }
+ },
+ "pt" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Intel. O Rosetta não está instalado, então o Homebrew não pode ser executado."
+ }
+ },
+ "ro" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Intel. Software‑ul Rosetta nu este instalat, așa că nu poate rula."
+ }
+ },
+ "ru" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Intel. Rosetta не установлена, поэтому он не может работать."
+ }
+ },
+ "sv" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Intel. Rosetta är inte installerad, så det går inte att köra."
+ }
+ },
+ "tr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Intel. Rosetta yüklü değil, bu yüzden çalışamaz."
+ }
+ },
+ "uk" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Intel. Rosetta не інстальовано, тож він не може працювати."
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Intel。未安装Rosetta,因此它无法运行。"
+ }
+ },
+ "zh-Hant" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Intel。未安裝Rosetta,因此無法執行。"
+ }
+ }
+ }
+ },
"Internet Plug-ins" : {
"localizations" : {
"cs" : {
diff --git a/Packages/PeelCore/Sources/PeelCore/Homebrew/Homebrew.swift b/Packages/PeelCore/Sources/PeelCore/Homebrew/Homebrew.swift
index e781e377..af70491a 100644
--- a/Packages/PeelCore/Sources/PeelCore/Homebrew/Homebrew.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Homebrew/Homebrew.swift
@@ -281,6 +281,11 @@ public struct HomebrewInstallation: Sendable, Hashable {
public var mayBeChangedByThisAccount: Bool { unwritable == nil }
+ /// Whether this is an Intel Homebrew on a Mac with Apple silicon, as Homebrew judges it (`cmd/vendor-install.sh`).
+ public var isIntelOnAppleSilicon: Bool {
+ HostArchitecture.isAppleSilicon && PathPattern.comparablePath(of: prefix) == "/usr/local"
+ }
+
public var caskroom: URL {
prefix.appending(path: "Caskroom", directoryHint: .isDirectory)
}
@@ -1311,6 +1316,18 @@ public enum Homebrew {
}
}
+ /// What starts `executable`. The Homebrew in `/usr/local` on a Mac with Apple silicon is an Intel one
+ /// (`cmd/vendor-install.sh`). Started as it is, its shell says arm64, which chooses the bottles, and its Ruby runs
+ /// translated and says Intel, so it runs whole through Rosetta (`man arch`), as `arch -x86_64 brew` does.
+ static func launch(
+ of executable: URL, _ arguments: [String],
+ isAppleSilicon: Bool = HostArchitecture.isAppleSilicon, hasRosetta: Bool = Rosetta.isInstalled
+ ) -> (program: String, arguments: [String]) {
+ let path = executable.path(percentEncoded: false)
+ guard isAppleSilicon, hasRosetta, path.hasPrefix("/usr/local/") else { return (path, arguments) }
+ return ("/usr/bin/arch", ["-x86_64", path] + arguments)
+ }
+
/// Runs `brew`, or `executable` when a test stands in for it, since a real upgrade would change this Mac. A run
/// shown to the person keeps what Homebrew writes `inWritingOrder`: its warnings and errors among its steps.
static func execute(
@@ -1328,14 +1345,14 @@ public enum Homebrew {
guard let executable else {
throw CommandFailure(output: Self.notInstalled)
}
- let path = executable.path(percentEncoded: false)
let environment = environment(
autoUpdate: autoUpdate, keeping: kept, executable: executable, readsTheAPI: readsTheAPI, home: home,
writesLinesAsTheyGo: writesLinesAsTheyGo
)
+ let launch = launch(of: executable, arguments)
switch await Subprocess.run(
- path, arguments, environment: environment, timeout: timeout, errorsIntoOutput: inWritingOrder,
- onOutput: onOutput
+ launch.program, launch.arguments, environment: environment, timeout: timeout,
+ errorsIntoOutput: inWritingOrder, onOutput: onOutput
) {
case .success(let output):
return Attempt(status: output.status, standardOutput: output.text, standardError: output.errorText)
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/HomebrewChoiceTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/HomebrewChoiceTests.swift
index 0810486e..eacaa442 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/HomebrewChoiceTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/HomebrewChoiceTests.swift
@@ -95,4 +95,23 @@ struct HomebrewChoiceTests {
let usual = Homebrew.environment(autoUpdate: false)["PATH"]
#expect(Homebrew.environment(autoUpdate: false, executable: standard)["PATH"] == usual)
}
+
+ @Test func runsTheHomebrewInUsrLocalThroughRosettaOnAppleSilicon() {
+ let intel = URL(filePath: "/usr/local/bin/brew")
+ let expected = ["-x86_64", "/usr/local/bin/brew", "--version"]
+
+ let translated = Homebrew.launch(of: intel, ["--version"], isAppleSilicon: true, hasRosetta: true)
+ #expect(translated.program == "/usr/bin/arch")
+ #expect(translated.arguments == expected)
+ for (brew, isAppleSilicon, hasRosetta) in [
+ (intel, false, false),
+ (intel, true, false),
+ (URL(filePath: "/opt/homebrew/bin/brew"), true, true),
+ (URL(filePath: "/opt/brew/bin/brew"), true, true),
+ ] {
+ let plain = Homebrew.launch(of: brew, ["--version"], isAppleSilicon: isAppleSilicon, hasRosetta: hasRosetta)
+ #expect(plain.program == brew.path(percentEncoded: false))
+ #expect(plain.arguments == ["--version"])
+ }
+ }
}
diff --git a/Peel/Views/Homebrew/HomebrewList.swift b/Peel/Views/Homebrew/HomebrewList.swift
index 4dba5694..bdc991a5 100644
--- a/Peel/Views/Homebrew/HomebrewList.swift
+++ b/Peel/Views/Homebrew/HomebrewList.swift
@@ -253,6 +253,13 @@ struct HomebrewList: View {
.help(Text(verbatim: location))
}
.labeledContentStyle(.oneLine)
+ if homebrew.installation?.isIntelOnAppleSilicon == true {
+ LabeledContent("Built For") {
+ Text(Rosetta.isInstalled
+ ? "Intel. Peel runs it through Rosetta."
+ : "Intel. Rosetta isn’t installed, so it can’t run.")
+ }
+ }
LabeledContent("Formulae") {
count(of: .formula)
}