coleam00/Archon · error
ENOENT
ENOENT
Error message
Failed to read version: package.json not found (bad installation?)
What it means
getDevVersion reads package.json from the installation to determine the dev/build version; when readFile fails with ENOENT it translates that into this explicit error, indicating the CLI was installed or packaged without package.json — a broken installation. This is a boundary translation so the user sees a meaningful message instead of a raw Node ENOENT stack.
Source
Thrown at packages/cli/src/commands/version.ts:42
interface PackageJson {
name: string;
version: string;
}
/**
* Get version for development mode (reads package.json)
*/
async function getDevVersion(): Promise<{ name: string; version: string }> {
// Read root package.json (monorepo version), not the CLI package's own
const pkgPath = join(SCRIPT_DIR, '../../../../package.json');
let content: string;
try {
content = await readFile(pkgPath, 'utf-8');
} catch (error) {
const err = error as NodeJS.ErrnoException;
if (err.code === 'ENOENT') {
throw new Error('Failed to read version: package.json not found (bad installation?)');
} else if (err.code === 'EACCES') {
throw new Error('Failed to read version: permission denied reading package.json');
}
throw new Error(`Failed to read version: ${err.message}`);
}
let pkg: PackageJson;
try {
pkg = JSON.parse(content) as PackageJson;
} catch (_error) {
throw new Error('Failed to read version: package.json is malformed');
}
return { name: pkg.name, version: pkg.version };
}
/**
* Get the git commit hash at runtime (dev mode).View on GitHub (pinned to 0773b97458)
Solutions
- Reinstall archon cleanly (bun install -g / npm i -g the package) so package.json ships with the installation.
- Verify the file exists at the location the binary resolves (`node -e "console.log(require.resolve('.../package.json'))"` or check the install dir).
- If using a packaged standalone binary, ensure the packaging step includes package.json in the bundle.
- Check PATH/symlinks point at the real install directory, not a stale copy.
Defensive patterns
Strategy: validation
Validate before calling
import { existsSync } from 'node:fs';
const pkgPath = new URL('../package.json', import.meta.url).pathname;
if (!existsSync(pkgPath)) {
throw new Error(`Installation incomplete: ${pkgPath} missing — reinstall the package before running version info`);
} Try / catch
try {
const info = await devInfo();
} catch (err) {
if (err instanceof Error && err.message.includes('package.json not found (bad installation?)')) {
// trigger a clean reinstall of the package
} else throw err;
} Prevention
- Install via the package manager (npm/bun install -g), not by copying binaries out of node_modules.
- Keep package.json out of .dockerignore when building images that run version info.
- Let interrupted installs fail loudly and rerun them rather than running from a half-extracted tree.
- Check symlinks on PATH point at the real install directory.
When it happens
Trigger: devInfo -> getDevVersion calls readFile(pkgPath) and Node rejects with code 'ENOENT': the resolved package.json path does not exist because the binary was moved out of its package tree, a partial/failed install, a stripped production bundle, or PKG_PATH resolving to the wrong directory (e.g. run from a copied standalone binary).
Common situations: Installing via a copied binary without its package layout; npm/bun install interrupted mid-extract; Docker image built with .dockerignore excluding package.json; running the CLI from a relocated symlink whose target tree is missing.
Related errors
- EACCES
- Failed to read version: ${err.message}
- tar extraction failed (exit ${exitCode}): ${details}
- Failed to move extracted web UI from ${tmpDir} to ${targetDi
- Failed to start detached workflow child (executable: ${cmd[0
AI-assisted analysis of coleam00/Archon@0773b97458 (2026-09-01).
Data as JSON: /api/errors/595b5156f7201bef.
Report an issue: GitHub.