can1357/oh-my-pi · error · Error

--binary: cannot infer arch from ${base} (expect arm64/x64 i

Error message

--binary: cannot infer arch from ${base} (expect arm64/x64 in filename)

What it means

When --binary is passed, the runner does not receive an explicit architecture; instead it infers arm64 vs x64 from the tarball/binary filename via regexes (arm64|aarch64 vs x64|x86[_-]?64|amd64). If the basename matches neither pattern, the runner cannot know which arch bucket to place it in and throws. It also sets cfg.build=false once a prebuilt binary is supplied, so misclassification would silently target the wrong arch.

Source

Thrown at packages/metaharness/src/runner.ts:243

				break;
			}
			case "--version":
				cfg.version = take(arg);
				break;
			case "--thinking":
				cfg.thinking = take(arg);
				break;
			case "--tarball":
				cfg.tarball = path.resolve(take(arg));
				cfg.install = "local";
				cfg.build = false;
				break;
			case "--binary": {
				const p = path.resolve(take(arg));
				const base = path.basename(p);
				if (/arm64|aarch64/.test(base)) cfg.binaryArm64 = p;
				else if (/x64|x86[_-]?64|amd64/.test(base)) cfg.binaryX64 = p;
				else throw new Error(`--binary: cannot infer arch from ${base} (expect arm64/x64 in filename)`);
				cfg.build = false;
				break;
			}
			case "--no-build":
				cfg.build = false;
				break;
			case "--agent-arg":
				cfg.agentArgs.push(take(arg));
				break;
			case "-l":
			case "--tasks":
			case "--n-tasks":
				cfg.tasks = Number(take(arg));
				break;
			case "-n":
			case "--concurrency":
			case "--n-concurrent":
				cfg.concurrency = Number(take(arg));

View on GitHub (pinned to 9690622007)

Solutions

  1. Rename the file to include the arch: e.g. `agent-arm64` or `agent-x64` before passing --binary.
  2. Use a recognized token: arm64/aarch64 for ARM, x64/x86_64/x86-64/amd64 for Intel/AMD.
  3. Symlink or copy: `cp dist/agent dist/agent-x64 && runner --binary dist/agent-x64`.
  4. Alternatively omit --binary and let the runner build from source (cfg.build defaults true).

Example fix

// before
runner --binary ./dist/coding-agent-linux
// after
runner --binary ./dist/coding-agent-linux-x64
Defensive patterns

Strategy: validation

Validate before calling

const base = path.basename(binaryPath);
const isArm = /arm64|aarch64/.test(base);
const isX64 = /x64|x86[_-]?64|amd64/.test(base);
if (!isArm && !isX64) throw new Error(`rename binary to include arm64 or x64: ${base}`);

Type guard

function hasArchInName(p: string): boolean {
  const b = path.basename(p);
  return /arm64|aarch64|x64|x86[_-]?64|amd64/.test(b);
}

Try / catch

try {
  await runHarness({ binary });
} catch (e) {
  if (e instanceof Error && e.message.includes("cannot infer arch")) {
    console.error("Rename the binary to embed its arch (e.g. agent-x64 or agent-arm64).");
  } else throw e;
}

Prevention

When it happens

Trigger: Passing `--binary ./dist/myapp` or `--binary ./build/agent-linux` where the filename contains no arch token at all, or only tokens like 'universal', 'latest', a version number, or an OS name.

Common situations: Renaming a binary to a short name before handing it to the harness; downloading a release asset whose name omits arch; building locally with a project that names outputs without arch suffixes.

Related errors


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