Skip to content

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

Recipe files for a Steam game installed in another library go into the game's folder there. A file or copy step names its path under drive C, in the environment's own Steam library (steamapps/common/Portal 2/portal2/cfg/autoexec.cfg), so a game on an external disk, which 0.10.13's drive letters make easy to add in Steam, never got its fix: the file went into a folder on C the game never reads. Portal 2 there kept its HDR map-load freeze with the recipe applied, and CS:GO Legacy or RaceRoom would start without the d3d9.dll their recipes copy. The game's Steam manifest now decides: when it puts the game in another library folder, the step writes into the game's folder there. Games in the environment's own library and every other path are untouched, and a stray folder the old behaviour left on C does not count. The page's applied state and Play's re-apply check follow the same folder. Four recipes have such steps (Portal, Portal 2, CS:GO Legacy, RaceRoom). Seven new tests, 490 green (2026-10-07).

Gauthier Piarrettef8ed66f747df
diff --git a/Sources/HighballApp/AppState.swift b/Sources/HighballApp/AppState.swift
index 935b2cd..a224c3e 100644
--- a/Sources/HighballApp/AppState.swift
+++ b/Sources/HighballApp/AppState.swift
@@ -468,7 +468,7 @@ final class AppState {
// An opt-in fix is the owner's call from the page, never Play's: it helps some Macs and
// breaks others (RaceRoom's newer Direct3D 9, highball-db#60). Play leaves it alone.
if let recipe = fixRecipe(for: item), !recipe.isOptIn,
- !bottle.settings.recipes.contains(recipe.id) || !recipe.artifactsPresent(driveC: bottle.driveC),
+ !bottle.settings.recipes.contains(recipe.id) || !recipe.artifactsPresent(driveC: bottle.driveC, steamGames: gamesByBottle[bottle.name] ?? []),
let engine = engine(for: bottle) {
// The engine comes first, whatever the steps: a recipe of plain notes that names r7
// used to auto-apply on r5 and launch there, so nobody was ever offered the engine
@@ -1434,7 +1434,7 @@ final class AppState {
guard let self else { return }
if target.installed { self.play(target) } else { self.installSteamGame(target) }
}
- if !env.settings.recipes.contains(recipe.id) || !recipe.artifactsPresent(driveC: env.driveC) {
+ if !env.settings.recipes.contains(recipe.id) || !recipe.artifactsPresent(driveC: env.driveC, steamGames: gamesByBottle[env.name] ?? []) {
applyRecipe(recipe.id, to: env, then: DoneState(
title: String(format: L("%@ installed"), recipe.title),
ctaTitle: String(format: target.installed ? L("Play %@") : L("Install %@"), displayTitle(item)),
diff --git a/Sources/HighballApp/GameDetailView.swift b/Sources/HighballApp/GameDetailView.swift
index e558410..b6a2710 100644
--- a/Sources/HighballApp/GameDetailView.swift
+++ b/Sources/HighballApp/GameDetailView.swift
@@ -28,7 +28,7 @@ struct GameDetailView: View {
private var fixRecipe: HighballKit.Recipe? { state.fixRecipe(for: item) }
private var fixApplied: Bool {
guard let fixRecipe, let bottle else { return false }
- return bottle.settings.recipes.contains(fixRecipe.id) && fixRecipe.artifactsPresent(driveC: bottle.driveC)
+ return bottle.settings.recipes.contains(fixRecipe.id) && fixRecipe.artifactsPresent(driveC: bottle.driveC, steamGames: state.gamesByBottle[bottle.name] ?? [])
}
private var running: GameSession? {
if let appid = item.steamAppID, let s = state.session(forAppID: appid) { return s }
diff --git a/Sources/HighballKit/Recipe.swift b/Sources/HighballKit/Recipe.swift
index 871c0ca..8399fc6 100644
--- a/Sources/HighballKit/Recipe.swift
+++ b/Sources/HighballKit/Recipe.swift
@@ -171,13 +171,39 @@ public struct Recipe: Codable, Sendable, Identifiable {
/// files back, and the environment still records the recipe as applied. Play then treats the
/// recipe as not applied, so the copy comes back before the launch (2026-09-11: CS:GO Legacy
/// reinstalled without its d3d9.dll would have launched on the wrong Direct3D).
- public func artifactsPresent(driveC: URL) -> Bool {
+ /// `steamGames` are the environment's Steam games, so a copy placed in a game's folder on
+ /// another library counts (see `target(of:driveC:steamGames:)`).
+ public func artifactsPresent(driveC: URL, steamGames: [SteamGame] = []) -> Bool {
steps.allSatisfy { step in
- if case let .copy(_, to, _) = step { return FileManager.default.fileExists(atPath: driveC.appending(path: to).path) }
+ if case let .copy(_, to, _) = step {
+ return FileManager.default.fileExists(atPath: Self.target(of: to, driveC: driveC, steamGames: steamGames).path)
+ }
return true
}
}
+ /// Where a `file` or `copy` step's file goes. Steps name it under drive C, and a step for a
+ /// Steam game names the game's folder in the environment's own library
+ /// ("Program Files (x86)/Steam/steamapps/common/Portal 2/portal2/cfg/autoexec.cfg"). Steam
+ /// keeps other library folders too, often on an external disk (0.10.13 gave those a drive
+ /// letter), and a game installed there never got its fix: the file went into a folder on C
+ /// the game never reads. When the game's Steam manifest puts it in another library, the file
+ /// goes into the game's folder there. The manifest decides, not a folder on C: the old
+ /// behaviour left one behind for every game it missed. Every other path, and every game in
+ /// the environment's own library, lands where the step says, as before.
+ public static func target(of path: String, driveC: URL, steamGames: [SteamGame]) -> URL {
+ let standard = driveC.appending(path: path)
+ let steam = "Program Files (x86)/Steam", common = "\(steam)/steamapps/common/"
+ guard path.hasPrefix(common) else { return standard }
+ let parts = path.dropFirst(common.count).split(separator: "/", maxSplits: 1).map(String.init)
+ guard parts.count == 2, parts[0] != "..", !parts[1].split(separator: "/").contains(where: { $0 == ".." }),
+ let game = steamGames.first(where: { $0.installdir.caseInsensitiveCompare(parts[0]) == .orderedSame }),
+ let library = game.libraryRoot, let folder = game.installFolder,
+ library.standardizedFileURL.path != driveC.appending(path: steam).standardizedFileURL.path,
+ FileManager.default.fileExists(atPath: folder.path) else { return standard }
+ return folder.appending(path: parts[1])
+ }
+
/// True when applying the recipe changes what a launch inherits: the renderer, the sync
/// mode or an environment variable. A Steam client that is already running keeps the
/// environment it started with (issues #22/#25), so a Play that auto-applied such a recipe
@@ -415,6 +441,10 @@ public struct RecipeRunner: Sendable {
notes.append("Kept this bottle's renderer (\(bottle.settings.renderer.rawValue)); the recipe suggests \(r.rawValue).")
}
}
+ // Read once, for the file and copy steps of a game installed in another Steam library.
+ let steamGames = recipe.steps.contains {
+ switch $0 { case .file, .copy: return true; default: return false }
+ } ? SteamLibrary.games(in: bottle) : []
for (i, step) in recipe.steps.enumerated() {
// The app parses these two lines into its progress display (#31): the step line
// becomes the stage, the hint line the "this is slow, don't worry" text under it.
@@ -539,14 +569,16 @@ public struct RecipeRunner: Sendable {
bottle.settings.windowsVersion = v
try await runner.setWindowsVersion(v)
case let .file(path, contents):
- let url = bottle.driveC.appending(path: path)
+ let url = Recipe.target(of: path, driveC: bottle.driveC, steamGames: steamGames)
try FileManager.default.createDirectory(at: url.deletingLastPathComponent(), withIntermediateDirectories: true)
try contents.write(to: url, atomically: true, encoding: .utf8)
+ if url != bottle.driveC.appending(path: path) { log?("[\(recipe.id)] wrote \(url.path), the game's folder in another Steam library") }
case let .copy(from, to, asNative):
guard let source = Self.copySource(engineRoot: engine.root, from) else {
throw HighballError.invalid("copy step: '\(from)' is not a file inside the engine")
}
- let dest = bottle.driveC.appending(path: to)
+ let dest = Recipe.target(of: to, driveC: bottle.driveC, steamGames: steamGames)
+ if dest != bottle.driveC.appending(path: to) { log?("[\(recipe.id)] copying to \(dest.path), the game's folder in another Steam library") }
try FileManager.default.createDirectory(at: dest.deletingLastPathComponent(), withIntermediateDirectories: true)
if FileManager.default.fileExists(atPath: dest.path) { try FileManager.default.removeItem(at: dest) }
if asNative {
diff --git a/Tests/HighballKitTests/RecipeGameFolderTests.swift b/Tests/HighballKitTests/RecipeGameFolderTests.swift
new file mode 100644
index 0000000..c5caa5c
--- /dev/null
+++ b/Tests/HighballKitTests/RecipeGameFolderTests.swift
@@ -0,0 +1,146 @@
+import XCTest
+@testable import HighballKit
+
+/// A recipe's file for a Steam game installed in another library (an external disk Steam knows
+/// as D:) goes into the game's folder there. Before, it went into a folder of the same name on C
+/// that the game never reads, so Portal 2 on an external disk kept HDR's freeze with its fix
+/// applied, and CS:GO Legacy or RaceRoom launched without the d3d9.dll their recipes copy.
+final class RecipeGameFolderTests: XCTestCase {
+ private var tmp: URL!
+ private let portal2 = "Program Files (x86)/Steam/steamapps/common/Portal 2/portal2/cfg/autoexec.cfg"
+
+ override func setUpWithError() throws {
+ tmp = FileManager.default.temporaryDirectory.appending(path: "hb-gamefolder-\(UUID().uuidString)", directoryHint: .isDirectory)
+ try FileManager.default.createDirectory(at: tmp, withIntermediateDirectories: true)
+ }
+
+ override func tearDownWithError() throws { try? FileManager.default.removeItem(at: tmp) }
+
+ private func write(_ text: String, to url: URL) throws {
+ try FileManager.default.createDirectory(at: url.deletingLastPathComponent(), withIntermediateDirectories: true)
+ try text.write(to: url, atomically: true, encoding: .utf8)
+ }
+
+ private func manifest(_ appid: Int, _ name: String, dir: String) -> String {
+ "\"AppState\"\n{\n\t\"appid\"\t\t\"\(appid)\"\n\t\"name\"\t\t\"\(name)\"\n\t\"StateFlags\"\t\t\"4\"\n\t\"installdir\"\t\t\"\(dir)\"\n}\n"
+ }
+
+ /// An environment with Steam on C and a second library at D:\SteamLibrary.
+ private func environment() throws -> (bottle: URL, driveC: URL, steam: URL, external: URL) {
+ let bottle = tmp.appending(path: "bottle", directoryHint: .isDirectory)
+ let steam = bottle.appending(path: "drive_c/Program Files (x86)/Steam", directoryHint: .isDirectory)
+ let external = tmp.appending(path: "Disk/SteamLibrary", directoryHint: .isDirectory)
+ try write("", to: steam.appending(path: "steam.exe"))
+ let dosdevices = bottle.appending(path: "dosdevices", directoryHint: .isDirectory)
+ try FileManager.default.createDirectory(at: dosdevices, withIntermediateDirectories: true)
+ try FileManager.default.createSymbolicLink(atPath: dosdevices.appending(path: "c:").path, withDestinationPath: "../drive_c")
+ try FileManager.default.createSymbolicLink(atPath: dosdevices.appending(path: "d:").path, withDestinationPath: tmp.appending(path: "Disk").path)
+ try write("""
+ "libraryfolders"
+ {
+ \t"0"
+ \t{
+ \t\t"path"\t\t"C:\\\\Program Files (x86)\\\\Steam"
+ \t}
+ \t"1"
+ \t{
+ \t\t"path"\t\t"D:\\\\SteamLibrary"
+ \t}
+ }
+ """, to: steam.appending(path: "steamapps/libraryfolders.vdf"))
+ try FileManager.default.createDirectory(at: external.appending(path: "steamapps"), withIntermediateDirectories: true)
+ return (bottle, bottle.appending(path: "drive_c", directoryHint: .isDirectory), steam, external)
+ }
+
+ private func install(_ appid: Int, _ name: String, dir: String, in library: URL) throws {
+ try write(manifest(appid, name, dir: dir), to: library.appending(path: "steamapps/appmanifest_\(appid).acf"))
+ try write("", to: library.appending(path: "steamapps/common/\(dir)/game.exe"))
+ }
+
+ func testAFileForAGameOnAnotherLibraryGoesIntoItsFolder() throws {
+ let env = try environment()
+ try install(620, "Portal 2", dir: "Portal 2", in: env.external)
+ let games = SteamLibrary.games(steamRoot: env.steam, bottleURL: env.bottle)
+ let want = env.external.appending(path: "steamapps/common/Portal 2/portal2/cfg/autoexec.cfg").standardizedFileURL.path
+ XCTAssertEqual(Recipe.target(of: portal2, driveC: env.driveC, steamGames: games).standardizedFileURL.path, want)
+ // The old behaviour left a folder of that name on C for every game it missed; the
+ // manifest still decides.
+ try write("mat_hdr_level 0\n", to: env.driveC.appending(path: portal2))
+ XCTAssertEqual(Recipe.target(of: portal2, driveC: env.driveC, steamGames: games).standardizedFileURL.path, want)
+ }
+
+ func testAGameInTheEnvironmentsOwnLibraryKeepsThePath() throws {
+ let env = try environment()
+ try install(620, "Portal 2", dir: "Portal 2", in: env.steam)
+ let games = SteamLibrary.games(steamRoot: env.steam, bottleURL: env.bottle)
+ XCTAssertEqual(games.map(\.appid), [620])
+ XCTAssertEqual(Recipe.target(of: portal2, driveC: env.driveC, steamGames: games), env.driveC.appending(path: portal2))
+ }
+
+ func testAGameThatIsNotThereKeepsThePath() throws {
+ let env = try environment()
+ XCTAssertEqual(Recipe.target(of: portal2, driveC: env.driveC, steamGames: []), env.driveC.appending(path: portal2))
+ // A manifest whose folder is gone (the disk holds the manifest of a deleted game).
+ try write(manifest(620, "Portal 2", dir: "Portal 2"), to: env.external.appending(path: "steamapps/appmanifest_620.acf"))
+ let games = SteamLibrary.games(steamRoot: env.steam, bottleURL: env.bottle)
+ XCTAssertEqual(Recipe.target(of: portal2, driveC: env.driveC, steamGames: games), env.driveC.appending(path: portal2))
+ }
+
+ func testOtherPathsAreUntouched() throws {
+ let env = try environment()
+ try install(620, "Portal 2", dir: "Portal 2", in: env.external)
+ let games = SteamLibrary.games(steamRoot: env.steam, bottleURL: env.bottle)
+ for path in ["users/steamuser/Documents/My Games/x.ini",
+ "Program Files (x86)/Steam/steamapps/common/Portal 2",
+ "Program Files (x86)/Steam/steamapps/common/Portal 2/../../../../etc/x",
+ "Program Files (x86)/Steam/steamapps/common/../x/y"] {
+ XCTAssertEqual(Recipe.target(of: path, driveC: env.driveC, steamGames: games), env.driveC.appending(path: path), path)
+ }
+ }
+
+ func testTheFolderNameMatchesWhateverItsCase() throws {
+ let env = try environment()
+ try install(4465480, "Counter-Strike: Global Offensive", dir: "CSGO Legacy", in: env.external)
+ let games = SteamLibrary.games(steamRoot: env.steam, bottleURL: env.bottle)
+ let path = "Program Files (x86)/Steam/steamapps/common/csgo legacy/bin/d3d9.dll"
+ XCTAssertEqual(Recipe.target(of: path, driveC: env.driveC, steamGames: games).standardizedFileURL.path,
+ env.external.appending(path: "steamapps/common/CSGO Legacy/bin/d3d9.dll").standardizedFileURL.path)
+ }
+
+ func testACopyInTheGamesFolderCountsAsPresent() throws {
+ let env = try environment()
+ try install(4465480, "Counter-Strike: Global Offensive", dir: "csgo legacy", in: env.external)
+ let games = SteamLibrary.games(steamRoot: env.steam, bottleURL: env.bottle)
+ let recipe = try JSONDecoder().decode(Recipe.self, from: Data("""
+ {"id": "csgo-legacy", "kind": "game", "title": "CS:GO", "steps": [
+ {"type": "copy", "from": "engine/lib/wine/i386-windows/d3d9.dll", "to": "Program Files (x86)/Steam/steamapps/common/csgo legacy/bin/d3d9.dll", "asNative": true}]}
+ """.utf8))
+ XCTAssertFalse(recipe.artifactsPresent(driveC: env.driveC, steamGames: games), "not copied yet")
+ try write("x", to: env.external.appending(path: "steamapps/common/csgo legacy/bin/d3d9.dll"))
+ XCTAssertTrue(recipe.artifactsPresent(driveC: env.driveC, steamGames: games))
+ XCTAssertFalse(recipe.artifactsPresent(driveC: env.driveC), "without the games, the path on C as before")
+ }
+
+ func testApplyWritesTheFileIntoTheGamesFolder() async throws {
+ let env = try environment()
+ try install(620, "Portal 2", dir: "Portal 2", in: env.external)
+ let manifestURL = URL(fileURLWithPath: #filePath)
+ .deletingLastPathComponent().deletingLastPathComponent().deletingLastPathComponent()
+ .appending(path: "spike/engine-manifest.json")
+ let engineManifest = try EngineManifest.load(from: manifestURL)
+ let engine = InstalledEngine(manifest: engineManifest, root: tmp.appending(path: "engine"))
+ let bottle = Bottle(url: env.bottle, settings: BottleSettings(name: "t", engineID: engineManifest.id))
+ let recipe = try JSONDecoder.highball.decode(Recipe.self, from: Data("""
+ {"id": "portal-2", "kind": "game", "title": "Portal 2", "requires": ["steam"], "renderer": null,
+ "steps": [{"type": "file", "path": "\(portal2)", "contents": "mat_hdr_level 2\\n"}],
+ "knownIssues": [], "lastVerified": null}
+ """.utf8))
+ var runner = RecipeRunner(engine: engine, bottle: bottle)
+ _ = try await runner.apply(recipe)
+ let written = env.external.appending(path: "steamapps/common/Portal 2/portal2/cfg/autoexec.cfg")
+ XCTAssertEqual(try String(contentsOf: written, encoding: .utf8), "mat_hdr_level 2\n")
+ XCTAssertFalse(FileManager.default.fileExists(atPath: env.driveC.appending(path: "Program Files (x86)/Steam/steamapps/common/Portal 2").path),
+ "nothing written into a folder on C the game never reads")
+ XCTAssertEqual(runner.bottle.settings.recipes, ["portal-2"])
+ }
+}