{"record":{"id":"7e5ee484581656eb","repo":"oven-sh/bun","slug":"usage-scriptpath-ssh-create-image-publish-i","errorCode":null,"errorMessage":"Usage: ./${scriptPath} [ssh|create-image|publish-image] [options]","messagePattern":"Usage: \\./(.+?) \\[ssh\\|create-image\\|publish-image\\] \\[options\\]","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/machine.mjs","lineNumber":1367,"sourceCode":"\n  // Extract\n  await spawnSafe([\"unzip\", \"-o\", zipPath, \"-d\", tmpdir()], { stdio: \"inherit\" });\n  chmodSync(localPacker, 0o755);\n\n  console.log(`[packer] Installed Packer ${version}`);\n  return localPacker;\n}\n\nasync function main() {\n  const { positionals } = parseArgs({\n    allowPositionals: true,\n    strict: false,\n  });\n\n  const [command] = positionals;\n  if (!/^(ssh|create-image|publish-image)$/.test(command)) {\n    const scriptPath = relative(process.cwd(), fileURLToPath(import.meta.url));\n    throw new Error(`Usage: ./${scriptPath} [ssh|create-image|publish-image] [options]`);\n  }\n\n  const { values: args } = parseArgs({\n    allowPositionals: true,\n    options: {\n      \"cloud\": { type: \"string\", default: \"aws\" },\n      \"os\": { type: \"string\", default: \"linux\" },\n      \"arch\": { type: \"string\", default: \"x64\" },\n      \"distro\": { type: \"string\" },\n      \"release\": { type: \"string\" },\n      \"name\": { type: \"string\" },\n      \"instance-type\": { type: \"string\" },\n      \"image-id\": { type: \"string\" },\n      \"image-name\": { type: \"string\" },\n      \"cpu-count\": { type: \"string\" },\n      \"memory-gb\": { type: \"string\" },\n      \"disk-size-gb\": { type: \"string\" },\n      \"preemptible\": { type: \"boolean\" },","sourceCodeStart":1349,"sourceCodeEnd":1385,"githubUrl":"https://github.com/oven-sh/bun/blob/8c5296ac459e8252d3cd702f3fbcbb0c249d95d5/scripts/machine.mjs#L1349-L1385","documentation":"scripts/machine.mjs validates its first positional argument against /^(ssh|create-image|publish-image)$/ and throws this usage line when it does not match, including when no command was given at all. It is a command-line contract check, not a runtime failure.","triggerScenarios":"Running `./scripts/machine.mjs` with zero arguments, a typo like `create_images` or `publish`, or an unknown subcommand. Because the first parseArgs uses strict:false, any leading positional that is not one of the three words becomes the command and fails the regex.","commonSituations":"Typos in CI pipeline commands; copy-pasting an outdated subcommand after the script's CLI was renamed; forgetting that options must come after the command.","solutions":["Invoke the script with one of: ssh, create-image, publish-image as the first argument","Put options after the subcommand (e.g. `./scripts/machine.mjs create-image --cloud=azure`)"],"exampleFix":"# before\n./scripts/machine.mjs create_images\n\n# after\n./scripts/machine.mjs create-image","handlingStrategy":"validation","validationCode":"const COMMANDS = new Set([\"ssh\", \"create-image\", \"publish-image\"]);\nconst command = process.argv[2];\nif (!COMMANDS.has(command ?? \"\")) {\n  console.error(`Unknown command ${JSON.stringify(command)}. Valid: ${[...COMMANDS].join(\" | \")}`);\n  process.exit(2);\n}","typeGuard":"const isMachineCommand = (v: string | undefined): v is \"ssh\" | \"create-image\" | \"publish-image\" =>\n  /^(ssh|create-image|publish-image)$/.test(v ?? \"\");","tryCatchPattern":null,"preventionTips":["Wrap machine.mjs invocations in CI scripts that validate the subcommand before spawning","Keep the usage string in CI docs next to each pipeline step"],"tags":["cli","usage","arguments"],"backgroundTag":null,"analyzedSha":"8c5296ac459e8252d3cd702f3fbcbb0c249d95d5","analyzedAt":"2026-08-16T08:01:58.794Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}