Run Windows games on Apple Silicon — free, open source, with an open compatibility database that tells you what actually works.
Swift apple-silicond3dmetaldxmtdxvkfexgame-porting-toolkitgamingmac-gamingmacosmetalmoltenvksteamswiftuivkd3d-protonwhisky-alternativewindows-gameswinewine-wrapper
fix: stale pins fail with a clear message, not opaque wine c0000135 (#23)
Gauthier Piarretteea5c88aa4778
diff --git a/Sources/HighballKit/Bottle.swift b/Sources/HighballKit/Bottle.swiftindex ea98c1c..15beea0 100644--- a/Sources/HighballKit/Bottle.swift+++ b/Sources/HighballKit/Bottle.swift@@ -70,7 +70,13 @@ public struct Pin: Codable, Sendable, Identifiable, Hashable {/// that made "Run and add to Programs" produce dead entries for outside-the-bottle exes.)public static func storagePath(for url: URL, driveC: URL) -> String {let prefix = driveC.path.hasSuffix("/") ? driveC.path : driveC.path + "/"- return url.path.hasPrefix(prefix) ? String(url.path.dropFirst(prefix.count)) : url.path+ // Case-insensitive: macOS APFS is case-insensitive by default, so a dropped URL's+ // casing can differ from the canonical bottles path. A case-sensitive match there+ // would wrongly store an absolute path for an in-bottle file.+ if url.path.lowercased().hasPrefix(prefix.lowercased()) {+ return String(url.path.dropFirst(prefix.count))+ }+ return url.path}enum CodingKeys: String, CodingKey { case id, name, path, arguments, environment, renderer }diff --git a/Sources/HighballKit/WineRunner.swift b/Sources/HighballKit/WineRunner.swiftindex e829478..311d595 100644--- a/Sources/HighballKit/WineRunner.swift+++ b/Sources/HighballKit/WineRunner.swift@@ -92,6 +92,13 @@ public struct WineRunner: Sendable {@discardableResultpublic func start(pin: Pin, extraEnvironment: [String: String] = [:], onOutput: (@Sendable (String) -> Void)? = nil) async throws -> LaunchResult {let exe = pin.executableURL(driveC: bottle.driveC)+ // A pin whose target no longer exists otherwise dies deep in Wine with an opaque+ // c0000135 ("failed to open"). Catch it here with a message the user can act on.+ // Pins written before 0.7.6 stored only a filename, so old entries resolve to a+ // drive_c-root path that isn't there (issue #23).+ guard FileManager.default.fileExists(atPath: exe.path) else {+ throw HighballError.invalid("\(pin.name) points at \(pin.path), which isn't there. If this was added by an older Highball, remove it and drag the program in again.")+ }let env = pin.environment.merging(extraEnvironment) { $1 }// cwd = the exe's folder, as a Windows shortcut would — games with relative asset paths need it.return try await start(exe, arguments: pin.arguments, renderer: pin.renderer, extraEnvironment: env,diff --git a/Tests/HighballKitTests/RegressionTests.swift b/Tests/HighballKitTests/RegressionTests.swiftindex 5125554..c00a4bb 100644--- a/Tests/HighballKitTests/RegressionTests.swift+++ b/Tests/HighballKitTests/RegressionTests.swift@@ -143,3 +143,36 @@ extension RegressionTests {XCTAssertFalse(markers.contains { "2026-08-26T104400Z-cyberpunk-Cyberpunk2077.exe.log".lowercased().contains($0) })}}++extension RegressionTests {+ // Pins written before 0.7.6 stored a bare filename, resolving to a drive_c-root path+ // that isn't there; launching them died with an opaque wine c0000135. Launch now+ // fails early with an actionable message (issue #23).+ func testStalePinFailsClearly() async throws {+ let manifestURL = URL(fileURLWithPath: #filePath)+ .deletingLastPathComponent().deletingLastPathComponent().deletingLastPathComponent()+ .appending(path: "spike/engine-manifest.json")+ let engine = InstalledEngine(manifest: try EngineManifest.load(from: manifestURL),+ root: FileManager.default.temporaryDirectory.appending(path: "hb-stale-\(UUID().uuidString)"))+ let bottleURL = FileManager.default.temporaryDirectory.appending(path: "hb-stale-bottle-\(UUID().uuidString)")+ try FileManager.default.createDirectory(at: bottleURL.appending(path: "drive_c"), withIntermediateDirectories: true)+ defer { try? FileManager.default.removeItem(at: bottleURL) }+ var settings = BottleSettings(name: "b", engineID: engine.id)+ settings.pins = [Pin(name: "Ghost", path: "Ghost.exe")] // bare filename, target absent+ let runner = WineRunner(engine: engine, bottle: Bottle(url: bottleURL, settings: settings))+ do {+ _ = try await runner.start(pin: settings.pins[0])+ XCTFail("launching a stale pin must throw")+ } catch {+ XCTAssertTrue("\(error)".contains("isn't there"), "error should be actionable: \(error)")+ }+ }++ // storagePath must match the bottle prefix case-insensitively (APFS default).+ func testStoragePathCaseInsensitive() {+ let driveC = URL(fileURLWithPath: "/Users/x/Highball/bottles/b/drive_c")+ // A dropped URL with different casing on the volume path segments.+ let mixed = URL(fileURLWithPath: "/Users/x/Highball/Bottles/b/drive_c/Games/g.exe")+ XCTAssertEqual(Pin.storagePath(for: mixed, driveC: driveC), "Games/g.exe")+ }+}