The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.
TypeScript 3d-modelingagent-frameworkagent-harnessai-agentscadclaude-codecodexcoding-agentsdeveloper-toolsesp32game-developmentmcp-servermulti-agentopen-hardwareopencodeopenharnesspcbroboticsterminaltmux
fix(cli): a dangling link on the engine search path no longer holds a start that has its engine later on PATH (#2325)
Kelvin30f5ec8610a2
diff --git a/cli/src/engines/kit/launchExecutable.spec.ts b/cli/src/engines/kit/launchExecutable.spec.tsindex b246c7303..0470350fa 100644--- a/cli/src/engines/kit/launchExecutable.spec.ts+++ b/cli/src/engines/kit/launchExecutable.spec.ts@@ -75,6 +75,39 @@ it('holds dangling command aliases instead of authorizing an installation over tsymlinkSync(join(root, 'unavailable-engine'), join(bin, 'opencode'))expect(await captureLaunchExecutable('opencode', '')).toMatchObject({ state: 'held' })})+// Nix (Determinate installer) puts ~/.nix-profile/bin on every login PATH, and ~/.nix-profile names a profile that+// is not there until `nix profile install` makes one. Holding at that link, every Claude Code start on such a Mac+// waited for good, its own claude in ~/.local/bin, later on the PATH, never reached (desktop 1.3.42, 2026-10-30).+it('looks past a dangling link on the search path, and still never installs with nothing found after it', async () => {+ vi.doMock('../../lib/engineLaunch.js', async (actual) => ({ ...await actual<object>(), npmRuntimeBins: () => [] }))+ const { bin, captureLaunchExecutable } = await fixture()+ vi.doUnmock('../../lib/engineLaunch.js')+ const profile = join(root, '.nix-profile'); symlinkSync(join(root, 'state', 'nix', 'profiles', 'profile'), profile)+ vi.stubEnv('PATH', [join(profile, 'bin'), bin].join(':'))+ expect(await captureLaunchExecutable('opencode', '')).toMatchObject({ state: 'held', detail: expect.stringContaining('aliases') })+ const file = join(bin, 'opencode'); writeFileSync(file, 'its own', { mode: 0o700 })+ expect(await captureLaunchExecutable('opencode', '')).toMatchObject({ state: 'ready', executable: { command: file } })+})+it('looks past a dangling command link to the engine after it, as a shell does', async () => {+ vi.doMock('../../lib/engineLaunch.js', async (actual) => ({ ...await actual<object>(), npmRuntimeBins: () => [] }))+ const { bin, captureLaunchExecutable } = await fixture()+ vi.doUnmock('../../lib/engineLaunch.js')+ const first = join(root, 'first'); mkdirSync(first)+ symlinkSync(join(root, 'removed-engine'), join(first, 'opencode'))+ vi.stubEnv('PATH', [first, bin].join(':'))+ expect(await captureLaunchExecutable('opencode', '')).toMatchObject({ state: 'held' })+ const file = join(bin, 'opencode'); writeFileSync(file, 'its own', { mode: 0o700 })+ expect(await captureLaunchExecutable('opencode', '')).toMatchObject({ state: 'ready', executable: { command: file } })+})+it('never looks past a configured engine path that is a dangling link', async () => {+ // The person named this file: there is nothing after it to look for.+ await fixture()+ const link = join(root, 'configured-opencode'); symlinkSync(join(root, 'removed-engine'), link)+ vi.stubEnv('OPENCODE_PATH', link)+ vi.resetModules()+ const { captureLaunchExecutable } = await import('./launchExecutable.js')+ expect(await captureLaunchExecutable('opencode', '')).toMatchObject({ state: 'held', detail: expect.stringContaining('aliases') })+})it('permits complete absence through a valid search-directory alias', async () => {const { bin, captureLaunchExecutable } = await fixture()const alias = join(root, 'path-alias'); symlinkSync(bin, alias); vi.stubEnv('PATH', alias)diff --git a/cli/src/engines/kit/launchExecutable.ts b/cli/src/engines/kit/launchExecutable.tsindex c47d3d6ad..e668480d4 100644--- a/cli/src/engines/kit/launchExecutable.ts+++ b/cli/src/engines/kit/launchExecutable.ts@@ -124,6 +124,12 @@ export async function captureLaunchExecutable(engine: AgentEngine, shell?: strin// A candidate this account may not reach. Looked past, for a later one it can run; with none, held as before rather// than installing over what may be there.let unreachable = false+ // A dangling link on the way to a candidate (POSIX): a person's choice, so it never proves the engine absent. Looked+ // past as bash and zsh look past it (ENOENT), for a later candidate it can run; with none, held rather than+ // installing. Held at the+ // link, every start on a Mac with Nix and no profile yet (~/.nix-profile) waited for good, its own Claude Code in+ // ~/.local/bin never reached (2026-10-30).+ let aliased = falsefor (const path of [...new Set(candidates.flatMap(windowsPrograms))]) {try {const info = statSync(path)@@ -136,6 +142,8 @@ export async function captureLaunchExecutable(engine: AgentEngine, shell?: strin// A leaf that exists though statSync cannot follow it is a dangling link: a user's choice, held as on POSIX.// Only the leaf is checked: a dangling folder on the way (nvm-windows' nodejs link after its version was// removed) still reads as absent here, where POSIX holds on a dangling ancestor.+ // Unlike a POSIX shell, Windows' search stops at the dangling leaf rather than looking past it, so it is+ // still held here, not looked past.if (process.platform === 'win32') {try { lstatSync(path) } catch (leaf) {if ((leaf as NodeJS.ErrnoException).code === 'ENOENT') continue@@ -150,7 +158,7 @@ export async function captureLaunchExecutable(engine: AgentEngine, shell?: strin// and missing descendants of valid aliases still prove absence.for (const fact of paths.snapshot()) if (fact.alias) statSync(fact.path)paths.verify()- } catch { return held('Waiting to confirm the engine search path and its aliases.') }+ } catch { aliased = true }continue}// A folder on the search path that this account may not enter, or a file it may not run, hides nothing it could@@ -165,6 +173,7 @@ export async function captureLaunchExecutable(engine: AgentEngine, shell?: strinif (!executable) return held('Waiting for the selected engine executable to stop changing.')return { state: 'ready', executable, environment: withNodeForScript(path, environment) }}+ if (aliased) return held('Waiting to confirm the engine search path and its aliases.')if (unreachable) return held('Waiting to confirm access to the selected engine executable.')return recipe ? { state: 'install', recipe, environment: environment as Record<string, string> } : held('Waiting for the configured engine executable to become available.')}diff --git a/cli/src/engines/kit/launchExecutable.windows.spec.ts b/cli/src/engines/kit/launchExecutable.windows.spec.tsindex 39f2bf5e5..0f9b43eab 100644--- a/cli/src/engines/kit/launchExecutable.windows.spec.ts+++ b/cli/src/engines/kit/launchExecutable.windows.spec.ts@@ -68,6 +68,13 @@ describe('the Windows engine search', () => {expect(await capture('C:\\tools')).toMatchObject({ state: 'held', detail: expect.stringContaining('aliases') })})+ it('holds at a dangling link even with an engine after it, where Windows stops too', async () => {+ // POSIX looks past it as bash and zsh do; Windows' search stops at the link, so a later engine is not what runs.+ dangling.add('c:\\tools\\codex.exe')+ files.add('c:\\later\\codex.cmd')+ expect(await capture('C:\\tools;C:\\later')).toMatchObject({ state: 'held', detail: expect.stringContaining('aliases') })+ })+it('treats a missing entry as absent and holds on any other error', async () => {expect(await capture('C:\\tools')).toMatchObject({ state: 'held' })vi.mocked(fs.statSync).mockImplementationOnce((() => { throw missing('x', 'EACCES') }) as never)