Skip to content

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.

Find an npm engine beside Harness's Node, and log why an installation check holds (#1418)

0xken155ec13021be2e
diff --git a/cli/src/engines/kit/launchExecutable.spec.ts b/cli/src/engines/kit/launchExecutable.spec.ts
index 897537981..82290386c 100644
--- a/cli/src/engines/kit/launchExecutable.spec.ts
+++ b/cli/src/engines/kit/launchExecutable.spec.ts
@@ -74,6 +74,19 @@ it('gives an npm engine Harness\'s Node, after the PATH, when the launch PATH ha
const result = await captureLaunchExecutable('opencode', '')
expect(result).toMatchObject({ state: 'ready', environment: { PATH: `${bin}:${dirname(managedNodePath())}` } })
})
+it('finds an npm engine beside Harness\'s Node, where its installer finds it', async () => {
+ // A Codex there was "missing" to the daemon only: each launch dispatched an installer that exited 0 (2026-10-19).
+ await fixture()
+ const runtime = join(root, 'runtime'), nodeBin = join(runtime, 'node-fixture', 'bin'); mkdirSync(nodeBin, { recursive: true })
+ writeFileSync(join(nodeBin, 'node'), '', { mode: 0o700 })
+ writeFileSync(join(runtime, 'current-node'), join(nodeBin, 'node'))
+ vi.stubEnv('ADAPTER_RUNTIME_DIR', runtime); vi.stubEnv('CODEX_PATH', '')
+ vi.resetModules()
+ const { captureLaunchExecutable } = await import('./launchExecutable.js')
+ expect(await captureLaunchExecutable('codex', '')).toMatchObject({ state: 'install' })
+ writeFileSync(join(nodeBin, 'codex'), '#!/usr/bin/env node\n', { mode: 0o700 })
+ expect(await captureLaunchExecutable('codex', '')).toMatchObject({ state: 'ready', executable: { command: join(nodeBin, 'codex') } })
+})
it('leaves the launch PATH alone for a Node the person has, and for an engine that is not a Node script', async () => {
const { bin, withNodeForScript } = await fixture()
const script = join(bin, 'codex'), node = join(root, 'harness-node', 'bin', 'node')
diff --git a/cli/src/engines/kit/launchExecutable.ts b/cli/src/engines/kit/launchExecutable.ts
index 57c040d2a..5815ada45 100644
--- a/cli/src/engines/kit/launchExecutable.ts
+++ b/cli/src/engines/kit/launchExecutable.ts
@@ -4,7 +4,7 @@ import { accessSync, closeSync, constants, openSync, readSync, statSync } from '
import { delimiter, dirname, isAbsolute, join, resolve } from 'node:path'
import { engineBin, enginePathOverride } from '../../lib/engineBin.js'
import { engineInstallPaths, engineInstallRecipe, type EngineInstallRecipe } from '../../lib/engineInstall.js'
-import { engineShellArgv, interactiveEngineShell } from '../../lib/engineLaunch.js'
+import { engineShellArgv, interactiveEngineShell, npmRuntimeBins } from '../../lib/engineLaunch.js'
import { managedNodePath } from '../../lib/nodeRuntime.js'
import { probeExecFile } from '../../lib/offThreadExec.js'
import { shellSingleQuote } from '../../lib/shellQuote.js'
@@ -100,6 +100,10 @@ export async function captureLaunchExecutable(engine: AgentEngine, shell?: strin
const names = [...new Set([command, ...(recipe?.executable.names ?? [])])]
const candidates = command.includes('/') ? [resolve(command)] : names.flatMap(name => entries.map(path => join(path, name)))
if (recipe) candidates.push(...engineInstallPaths(recipe, environment.HOME))
+ // The installer also finds an npm engine beside Harness's own Node (its PATH gains that folder, and
+ // `npm prefix -g` names it). Looking only here, a Codex in that folder was "missing": every launch dispatched
+ // an installer that found it and exited 0 without a word, and the next launch dispatched another (2026-10-19).
+ if (recipe?.executable.npmGlobal) candidates.push(...npmRuntimeBins().flatMap(bin => recipe.executable.names.map(name => join(bin, name))))
for (const path of [...new Set(candidates)]) {
try {
const info = statSync(path)
diff --git a/cli/src/engines/kit/nativeInstall.spec.ts b/cli/src/engines/kit/nativeInstall.spec.ts
index 0dbf292df..b97cc5046 100644
--- a/cli/src/engines/kit/nativeInstall.spec.ts
+++ b/cli/src/engines/kit/nativeInstall.spec.ts
@@ -334,6 +334,15 @@ it('keeps its history when a reboot renumbers the disk', async () => {
expect(restarted.dispatch).not.toHaveBeenCalled()
})
+it('logs why a failed check holds, which the person never sees', async () => {
+ await controller().ensure('opencode', recipe, environment, 'request', () => true)
+ complete()
+ unlinkSync(`${directory}.00000000.dispatch`)
+ const warn = vi.spyOn(console, 'warn').mockImplementation(() => {})
+ expect(await controller().status('codex', 'other', () => true)).toEqual({ complete: false, detail: 'Waiting to confirm durable engine installation ownership.' })
+ expect(warn).toHaveBeenCalledWith('[native-install] codex held:', 'Missing installation dispatch witness')
+})
+
it('confirms a readable result durably before crediting it or dispatching its successor', async () => {
await controller().ensure('opencode', recipe, environment, 'request', () => true)
complete()
diff --git a/cli/src/engines/kit/nativeInstall.ts b/cli/src/engines/kit/nativeInstall.ts
index 46d47530e..22cc5016e 100644
--- a/cli/src/engines/kit/nativeInstall.ts
+++ b/cli/src/engines/kit/nativeInstall.ts
@@ -339,7 +339,12 @@ export function createNativeInstallations({ directory, node = managedNodePath, d
if (!dispatchCurrent()) return hold('Waiting to confirm the installer claim.')
dispatch(runtime, file, hash)
return running('Installing the required engine. The saved launch continues after installation is confirmed.')
- } catch { return hold('Waiting to confirm durable engine installation ownership.') }
+ } catch (error) {
+ // Any failed check lands here, and the person sees only this line. Without the reason in the log, a hold
+ // that never cleared could only be traced by hand over many round trips with the user (2026-10-19).
+ console.warn(`[native-install] ${engine} held:`, error instanceof Error ? error.message : error)
+ return hold('Waiting to confirm durable engine installation ownership.')
+ }
}
const ensure = async (engine: AgentEngine, recipe: EngineInstallRecipe, environment: Record<string, string>, request: string, current: () => boolean): Promise<NativeInstallation> =>
(await examine(engine, recipe, environment, request, current))!
diff --git a/cli/src/lib/engineLaunch.ts b/cli/src/lib/engineLaunch.ts
index a12bf0b86..d941dfd44 100644
--- a/cli/src/lib/engineLaunch.ts
+++ b/cli/src/lib/engineLaunch.ts
@@ -973,9 +973,14 @@ function installFirstScript(install: string): string {
* otherwise prepend the managed runtime's bin directory for this pane only. This is portable across
* macOS and Linux and avoids an interactive/root package-manager install in an agent launch.
*/
+/** Harness's own Node folders. An npm engine run through them (`npm install -g` without a prefix) lands here. */
+export function npmRuntimeBins(runtimeNode: string = managedNodePath()): string[] {
+ return [...new Set([dirname(runtimeNode), dirname(baseNode(process.execPath))])]
+}
+
function npmRuntimePrelude(recipe: EngineInstallRecipe, runtimeNode: string): string {
if (!recipe.executable.npmGlobal) return ''
- const bins = [...new Set([dirname(runtimeNode), dirname(baseNode(process.execPath))])]
+ const bins = npmRuntimeBins(runtimeNode)
.map(shellSingleQuote)
.join(' ')
return [