can1357/oh-my-pi · error · Error

Unable to resolve ${ONNX_RUNTIME_NODE_PACKAGE} in compiled r

Error message

Unable to resolve ${ONNX_RUNTIME_NODE_PACKAGE} in compiled runtime at ${nodeModules}

What it means

Before repairing CUDA providers, ensureOnnxRuntimeCudaProviders resolves onnxruntime-node/package.json inside the compiled side runtime's node_modules. If the module cannot be resolved at all, the runtime cache is broken or incomplete and the function throws immediately rather than attempting an install.

Source

Thrown at packages/coding-agent/src/subprocess/worker-runtime.ts:242

		throw new Error(
			`Failed to install ONNX Runtime CUDA provider binaries into ${binDir} with ${process.execPath} ${script} (exit ${exitCode}). Remove the tiny-model side runtime cache at ${runtimeDir} and retry with network access. ${output}`,
		);
	}
}

/**
 * Repairs the compiled Transformers side runtime when CUDA was requested and
 * Bun skipped `onnxruntime-node`'s NuGet sidecar install.
 */
export async function ensureOnnxRuntimeCudaProviders(
	runtimeDir: string,
	device = process.env.PI_TINY_DEVICE,
): Promise<void> {
	if (!shouldInstallOnnxRuntimeCudaProviders(device)) return;
	const nodeModules = path.join(runtimeDir, "node_modules");
	const manifest = resolveRuntimeModule(nodeModules, `${ONNX_RUNTIME_NODE_PACKAGE}/package.json`);
	if (!manifest)
		throw new Error(`Unable to resolve ${ONNX_RUNTIME_NODE_PACKAGE} in compiled runtime at ${nodeModules}`);
	const packageDir = path.dirname(manifest);
	const binDir = path.join(packageDir, LINUX_X64_ONNX_RUNTIME_CUDA_PROVIDER_DIR);
	const missing = await missingOnnxRuntimeCudaProviderFiles(binDir);
	if (missing.length === 0) return;

	await installOnnxRuntimeCudaProviders(packageDir, runtimeDir, binDir);
	const stillMissing = await missingOnnxRuntimeCudaProviderFiles(binDir);
	if (stillMissing.length === 0) return;
	throw new Error(
		`ONNX Runtime CUDA provider install completed but ${stillMissing.join(", ")} are still missing from ${binDir}. Remove the tiny-model side runtime cache at ${runtimeDir} and retry.`,
	);
}

/**
 * Prepare a freshly-installed compiled runtime for loading and return the
 * absolute entrypoint of `packageName` to `require`.
 */
async function prepareCompiledRuntime(runtimeDir: string, packageName: string): Promise<string> {

View on GitHub (pinned to 9690622007)

Solutions

  1. Delete the side runtime cache directory (runtimeDir) and relaunch so it is reinstalled from scratch.
  2. Reinstall ensuring optional dependencies are included (do not pass --omit=optional / --no-optional).
  3. Check that ONNXRUNTIME_NODE_INSTALL env var is not set to 'skip' in your environment.
  4. Set PI_TINY_DEVICE=cpu if CUDA is unnecessary, bypassing this code path.

Example fix

// before: side runtime missing onnxruntime-node
runtimeDir/node_modules/  (no onnxruntime-node)
// after
rm -rf <runtimeDir> && omp   # reinstall includes onnxruntime-node
Defensive patterns

Strategy: validation

Validate before calling

import { existsSync } from "node:fs";
const ok = existsSync(path.join(runtimeDir, "node_modules", "onnxruntime-node", "package.json"));
if (!ok) await fs.rm(runtimeDir, { recursive: true, force: true }); // force clean reinstall first

Try / catch

try {
  await ensureOnnxRuntimeCudaProviders(runtimeDir, device);
} catch (err) {
  if (String(err.message).includes("Unable to resolve onnxruntime-node")) {
    await fs.rm(runtimeDir, { recursive: true, force: true });
    // re-trigger runtime install, then retry once
  } else throw err;
}

Prevention

When it happens

Trigger: loadTransformersRuntime -> ensureOnnxRuntimeCudaProviders on linux x64 with PI_TINY_DEVICE=cuda/gpu/auto, when resolveRuntimeModule(runtimeDir/node_modules, 'onnxruntime-node/package.json') returns null — the package is absent from the extracted compiled runtime.

Common situations: Incomplete extraction of the compiled runtime archive, optional dependencies skipped during install (ONNXRUNTIME_NODE_INSTALL=skip or --no-optional), or the user manually deleted parts of the side-runtime cache.

Related errors


AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31). Data as JSON: /api/errors/b4a70b049f3b7294. Report an issue: GitHub.