Skip to content

Run Windows games on Apple Silicon — free, open source, with an open compatibility database that tells you what actually works.

Rosetta is checked by running an Intel program, and a Bad CPU type launch failure says how to install it (#101)

Gauthier Piarrette7b9f287befda
diff --git a/Sources/HighballApp/AppState.swift b/Sources/HighballApp/AppState.swift
index 842c44d..b45142f 100644
--- a/Sources/HighballApp/AppState.swift
+++ b/Sources/HighballApp/AppState.swift
@@ -492,7 +492,7 @@ final class AppState {
bottles = (try? bottleStore.list()) ?? []
damagedBottles = (try? bottleStore.damaged()) ?? []
needsOnboarding = engines.isEmpty && homeUnavailable == nil // an unplugged drive is not a first run
- rosettaInstalled = FileManager.default.fileExists(atPath: "/Library/Apple/usr/share/rosetta/rosetta")
+ rosettaInstalled = Self.rosettaWorks()
// Drop a selection whose bottle is gone, not merely a nil one: a delete that threw after
// the bottle had in fact been removed (the losing side of a race) left the selection
// pinned to a name nothing could resolve.
@@ -787,6 +787,19 @@ final class AppState {
}
}
+ /// Whether Intel code runs on this Mac: an actual Intel program is executed rather than a
+ /// file looked for, because a Mac on macOS 27 reported "Bad CPU type in executable" on every
+ /// Wine launch while the old file check said Rosetta was there (issue #101).
+ nonisolated static func rosettaWorks() -> Bool {
+ let p = Process()
+ p.executableURL = URL(fileURLWithPath: "/usr/bin/arch")
+ p.arguments = ["-x86_64", "/usr/bin/true"]
+ p.standardOutput = FileHandle.nullDevice; p.standardError = FileHandle.nullDevice
+ do { try p.run() } catch { return false }
+ p.waitUntilExit()
+ return p.terminationStatus == 0
+ }
+
/// `softwareupdate` installs Rosetta for a normal user on Apple silicon; when it cannot,
/// the error names the one command that does, so the recovery card can show it.
static func installRosetta() async throws {
@@ -797,7 +810,7 @@ final class AppState {
try p.run(); p.waitUntilExit()
return (p.terminationStatus, String(decoding: pipe.fileHandleForReading.readDataToEndOfFile(), as: UTF8.self))
}.value
- let installed = FileManager.default.fileExists(atPath: "/Library/Apple/usr/share/rosetta/rosetta")
+ let installed = rosettaWorks()
guard out.0 == 0 || installed else {
throw HighballError.failed("Rosetta did not install. In Terminal, run: softwareupdate --install-rosetta --agree-to-license, then press Get started again. (\(out.1.trimmingCharacters(in: .whitespacesAndNewlines).suffix(200)))")
}
diff --git a/Sources/HighballKit/WineRunner.swift b/Sources/HighballKit/WineRunner.swift
index 288c200..399ee4d 100644
--- a/Sources/HighballKit/WineRunner.swift
+++ b/Sources/HighballKit/WineRunner.swift
@@ -146,7 +146,15 @@ public struct WineRunner: Sendable {
process.standardError = pipe
let start = Date()
- do { try process.run() } catch { try? logHandle.close(); throw error }
+ do { try process.run() } catch {
+ try? logHandle.close()
+ // EBADARCH: macOS will not run Intel code, so Rosetta is missing or broken. Say that,
+ // not "Bad CPU type in executable" (issue #101).
+ if (error as NSError).code == 86 || error.localizedDescription.contains("Bad CPU type") {
+ throw HighballError.failed("Rosetta, Apple's layer for Intel programs, is not working on this Mac, and Highball's Wine engine needs it. In Terminal run: softwareupdate --install-rosetta --agree-to-license, then try again.")
+ }
+ throw error
+ }
let reader = pipe.fileHandleForReading
// The exit code used to be computed and thrown away: a failed install produced a log