{"record":{"id":"d3dc6eb9bd1376fc","repo":"apple/pkl","slug":"error-missing-option-0","errorCode":null,"errorMessage":"Error: missing option --{0}","messagePattern":"Error: missing option --(.+?)","errorType":"console","errorClass":"MissingOption","httpStatus":null,"severity":"error","filePath":"pkl-cli/src/main/kotlin/org/pkl/cli/CliCommandRunner.kt","lineNumber":167,"sourceCode":"    init {\n      spec.options.forEach { opt ->\n        when (opt) {\n          is CommandSpec.Flag ->\n            registerOption(\n              option(\n                  names = opt.names,\n                  help = opt.helpText ?: \"\",\n                  metavar = opt.metavar,\n                  hidden = opt.hidden,\n                  completionCandidates = opt.completionCandidates?.toClikt(),\n                )\n                .convert {\n                  try {\n                    opt.transformEach.apply(it, workingDirUri)\n                  } catch (e: CommandSpec.Option.BadValue) {\n                    fail(e.message!!)\n                  } catch (_: CommandSpec.Option.MissingOption) {\n                    throw MissingOption(option)\n                  }\n                }\n                .transformAll(opt.defaultValue, opt.showAsRequired) {\n                  try {\n                    opt.transformAll.apply(it, workingDirUri)\n                  } catch (e: CommandSpec.Option.BadValue) {\n                    fail(e.message!!)\n                  } catch (_: CommandSpec.Option.MissingOption) {\n                    throw MissingOption(option)\n                  }\n                }\n            )\n          is CommandSpec.BooleanFlag ->\n            registerOption(\n              if (opt.defaultValue != null)\n                option(names = opt.names, help = opt.helpText ?: \"\", hidden = opt.hidden)\n                  .flag(\"--no-${opt.name}\", default = opt.defaultValue!!)\n              else","sourceCodeStart":149,"sourceCodeEnd":185,"githubUrl":"https://github.com/apple/pkl/blob/f3efcbfc9b60d30053b0536d664948d7aa1b8673/pkl-cli/src/main/kotlin/org/pkl/cli/CliCommandRunner.kt#L149-L185","documentation":"The CLI argument-parsing bridge in CliCommandRunner translates picocli's internal missing-option signal into a typed MissingOption error formatted as \"Error: missing option --{0}\". It is thrown while converting values of a synthesized (generated) run command when a required option was not supplied on the command line.","triggerScenarios":"Invoking a generated/synthesized run subcommand (e.g. via `pkl eval` command synthesis) while omitting a required option like `--project` or another option with showAsRequired=true; picocli raises CommandSpec.Option.MissingOption during transformAll conversion.","commonSituations":"Running `pkl eval script.pkl` where the project requires a mandatory CLI option; CI pipelines where the required flag was dropped from the command template; version upgrades that turned an option required.","solutions":["Add the required option to the command line, e.g. `pkl ... --<option> <value>`","Run the command with `--help` to list required options","Check project/ProjectOptions configuration to see why the option is marked required"],"exampleFix":"// before\npkl eval script.pkl\n// after\npkl eval script.pkl --required-option value","handlingStrategy":"try-catch","validationCode":"// shell check before invoking\nrequired_opts=(--project)\nfor o in \"${required_opts[@]}\"; do\n  [[ \" $* \" == *\" $o \"* ]] || { echo \"missing option $o\" >&2; exit 2; }\ndone","typeGuard":null,"tryCatchPattern":"try {\n  cli.run(args)\n} catch (e: CliException) {\n  if (e is MissingOption) System.err.println(\"Provide ${e.optionName}, see --help\")\n  else throw e\n}","preventionTips":["Always pass required flags explicitly in scripts, never rely on defaults","Use `--help` to audit which options are showAsRequired","Avoid unquoted empty shell variables for option values"],"tags":["cli","pkl","missing-option","picocli"],"backgroundTag":"missing-required-option","analyzedSha":"f3efcbfc9b60d30053b0536d664948d7aa1b8673","analyzedAt":"2026-09-08T13:10:45.570Z","contentChangedAt":"2026-09-08T13:10:45.570Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}