Skip to content

The agent that grows with you

fix(desktop): pin the bootstrap marker with the probed git, not the first PATH hit

teknium135a3f0357189
diff --git a/apps/desktop/electron/bootstrap-runner-git-binary.test.ts b/apps/desktop/electron/bootstrap-runner-git-binary.test.ts
new file mode 100644
index 00000000000..fa73a97c1ee
--- /dev/null
+++ b/apps/desktop/electron/bootstrap-runner-git-binary.test.ts
@@ -0,0 +1,21 @@
+import assert from 'node:assert/strict'
+import type * as ChildProcess from 'node:child_process'
+
+import { test, vi } from 'vitest'
+
+const execFileSyncMock = vi.fn((..._args: unknown[]) => 'abcdef1234567890\n')
+
+vi.mock('node:child_process', async importOriginal => ({
+ ...(await importOriginal<typeof ChildProcess>()),
+ execFileSync: execFileSyncMock
+}))
+
+test('resolveCheckoutHead runs the probed git binary, not the first PATH hit (#114718)', async () => {
+ // The bootstrap marker pin used a bare `git`, which on the reported Mac is
+ // an Intel-only /usr/local/bin/git that fails at spawn, silently dropping
+ // the real pin. main.ts now passes the binary it already probed.
+ const { resolveCheckoutHead } = await import('./bootstrap-runner')
+
+ assert.equal(resolveCheckoutHead('/repo', { gitBinary: '/usr/bin/git' }), 'abcdef1234567890')
+ assert.equal(execFileSyncMock.mock.calls[0]?.[0], '/usr/bin/git')
+})
diff --git a/apps/desktop/electron/bootstrap-runner.ts b/apps/desktop/electron/bootstrap-runner.ts
index 90b3f55731d..377d07249a7 100644
--- a/apps/desktop/electron/bootstrap-runner.ts
+++ b/apps/desktop/electron/bootstrap-runner.ts
@@ -62,15 +62,20 @@ type ResolveHeadFn = (activeRoot: string | null | undefined) => string | null
* (all-zero) install stamps still produce a marker that
* isBootstrapComplete() accepts (pinnedCommit length >= 7).
*/
-function resolveCheckoutHead(activeRoot: string | null | undefined, opts: { execGit?: ExecGitFn } = {}): string | null {
+function resolveCheckoutHead(
+ activeRoot: string | null | undefined,
+ opts: { execGit?: ExecGitFn; gitBinary?: string } = {}
+): string | null {
if (!activeRoot) {
return null
}
+ // Bare 'git' takes the first PATH hit, which can exist yet be unlaunchable
+ // (Intel-only build on Apple Silicon); main.ts passes its probed binary.
const run: ExecGitFn =
opts.execGit ||
((args, cwd) =>
- execFileSync('git', args, {
+ execFileSync(opts.gitBinary || 'git', args, {
cwd,
encoding: 'utf8',
stdio: ['ignore', 'pipe', 'ignore'],
@@ -900,7 +905,8 @@ async function runBootstrap(opts) {
logRoot,
onEvent,
abortSignal,
- writeMarker // callback to write the bootstrap-complete marker; main.ts provides
+ writeMarker, // callback to write the bootstrap-complete marker; main.ts provides
+ gitBinary // probed git path from main.ts; bare 'git' when absent
} = opts
// Bail before spawning anything if the user already cancelled — otherwise an
@@ -1021,7 +1027,9 @@ async function runBootstrap(opts) {
// not real pins -- resolve HEAD from the checkout we just installed so
// isBootstrapComplete() (pinnedCommit.length >= 7) accepts the marker
// instead of re-running bootstrap on every launch (#50823 review).
- const pinnedCommit = resolveMarkerPinnedCommit(installStamp, activeRoot)
+ const pinnedCommit = resolveMarkerPinnedCommit(installStamp, activeRoot, {
+ resolveHead: root => resolveCheckoutHead(root, { gitBinary })
+ })
if (!pinnedCommit) {
emit({
diff --git a/apps/desktop/electron/main.ts b/apps/desktop/electron/main.ts
index d8a8141c447..3ad303adcee 100644
--- a/apps/desktop/electron/main.ts
+++ b/apps/desktop/electron/main.ts
@@ -5409,7 +5409,8 @@ async function runEnsureRuntime(backend: any, assertStillOwned: () => void): Pro
void 0
}
},
- writeMarker: writeBootstrapMarker
+ writeMarker: writeBootstrapMarker,
+ gitBinary: resolveGitBinary()
})
bootstrapAbortController = null