{"record":{"id":"26fe0c2df37e7573","repo":"can1357/oh-my-pi","slug":"binary-cannot-infer-arch-from-base-expect-a","errorCode":null,"errorMessage":"--binary: cannot infer arch from ${base} (expect arm64/x64 in filename)","messagePattern":"--binary: cannot infer arch from (.+?) \\(expect arm64/x64 in filename\\)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/metaharness/src/runner.ts","lineNumber":243,"sourceCode":"\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"--version\":\n\t\t\t\tcfg.version = take(arg);\n\t\t\t\tbreak;\n\t\t\tcase \"--thinking\":\n\t\t\t\tcfg.thinking = take(arg);\n\t\t\t\tbreak;\n\t\t\tcase \"--tarball\":\n\t\t\t\tcfg.tarball = path.resolve(take(arg));\n\t\t\t\tcfg.install = \"local\";\n\t\t\t\tcfg.build = false;\n\t\t\t\tbreak;\n\t\t\tcase \"--binary\": {\n\t\t\t\tconst p = path.resolve(take(arg));\n\t\t\t\tconst base = path.basename(p);\n\t\t\t\tif (/arm64|aarch64/.test(base)) cfg.binaryArm64 = p;\n\t\t\t\telse if (/x64|x86[_-]?64|amd64/.test(base)) cfg.binaryX64 = p;\n\t\t\t\telse throw new Error(`--binary: cannot infer arch from ${base} (expect arm64/x64 in filename)`);\n\t\t\t\tcfg.build = false;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"--no-build\":\n\t\t\t\tcfg.build = false;\n\t\t\t\tbreak;\n\t\t\tcase \"--agent-arg\":\n\t\t\t\tcfg.agentArgs.push(take(arg));\n\t\t\t\tbreak;\n\t\t\tcase \"-l\":\n\t\t\tcase \"--tasks\":\n\t\t\tcase \"--n-tasks\":\n\t\t\t\tcfg.tasks = Number(take(arg));\n\t\t\t\tbreak;\n\t\t\tcase \"-n\":\n\t\t\tcase \"--concurrency\":\n\t\t\tcase \"--n-concurrent\":\n\t\t\t\tcfg.concurrency = Number(take(arg));","sourceCodeStart":225,"sourceCodeEnd":261,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/metaharness/src/runner.ts#L225-L261","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Rename the file to include the arch: e.g. `agent-arm64` or `agent-x64` before passing --binary.","Use a recognized token: arm64/aarch64 for ARM, x64/x86_64/x86-64/amd64 for Intel/AMD.","Symlink or copy: `cp dist/agent dist/agent-x64 && runner --binary dist/agent-x64`.","Alternatively omit --binary and let the runner build from source (cfg.build defaults true)."],"exampleFix":"// before\nrunner --binary ./dist/coding-agent-linux\n// after\nrunner --binary ./dist/coding-agent-linux-x64","handlingStrategy":"validation","validationCode":"const base = path.basename(binaryPath);\nconst isArm = /arm64|aarch64/.test(base);\nconst isX64 = /x64|x86[_-]?64|amd64/.test(base);\nif (!isArm && !isX64) throw new Error(`rename binary to include arm64 or x64: ${base}`);","typeGuard":"function hasArchInName(p: string): boolean {\n  const b = path.basename(p);\n  return /arm64|aarch64|x64|x86[_-]?64|amd64/.test(b);\n}","tryCatchPattern":"try {\n  await runHarness({ binary });\n} catch (e) {\n  if (e instanceof Error && e.message.includes(\"cannot infer arch\")) {\n    console.error(\"Rename the binary to embed its arch (e.g. agent-x64 or agent-arm64).\");\n  } else throw e;\n}","preventionTips":["Adopt a build naming convention that always includes the arch token.","Symlink arch-suffixed names next to binaries before handing them to tools.","Never strip arch from release asset filenames."],"tags":["cli","argument-validation","architecture","filename"],"backgroundTag":"cannot-infer-arch-from-filename","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}