{"record":{"id":"827b9f0474fe447a","repo":"apple/pkl","slug":"missing-argument-argument","errorCode":null,"errorMessage":"Missing argument \"${argument}\".","messagePattern":"Missing argument \"(.+?)\"\\.","errorType":"console","errorClass":"MissingArgument","httpStatus":null,"severity":"error","filePath":"pkl-cli/src/main/kotlin/org/pkl/cli/CliCommandRunner.kt","lineNumber":209,"sourceCode":"              option(names = opt.names, help = opt.helpText ?: \"\", hidden = opt.hidden)\n                .int()\n                .transformValues(0..0) { it.lastOrNull() ?: 1 }\n                .transformAll { it.sum().toLong() }\n            )\n          is CommandSpec.Argument ->\n            registerArgument(\n              argument(\n                  opt.name,\n                  opt.helpText ?: \"\",\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 MissingArgument(argument)\n                  }\n                }\n                .transformAll(if (opt.repeated) -1 else 1, !opt.repeated) {\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 MissingArgument(argument)\n                  }\n                }\n            )\n        }\n      }\n      spec.subcommands.forEach { subcommands(SynthesizedRunCommand(it, runner)) }\n    }\n\n    val workingDirUri: URI by lazy { runner.options.normalizedWorkingDir.toUri() }","sourceCodeStart":191,"sourceCodeEnd":227,"githubUrl":"https://github.com/apple/pkl/blob/f3efcbfc9b60d30053b0536d664948d7aa1b8673/pkl-cli/src/main/kotlin/org/pkl/cli/CliCommandRunner.kt#L191-L227","documentation":"While converting positional argument values in a synthesized run command, a CommandSpec.Option.MissingOption from picocli is rethrown as MissingArgument(argument), producing \"Missing argument \\\"<name>\\\".\". It means a required positional argument (such as the module argument) was not provided.","triggerScenarios":"Invoking a synthesized command without its required positional argument; picocli raises MissingOption during the transformEach conversion of the argument and the runner maps it to MissingArgument.","commonSituations":"Running `pkl run` or a synthesized subcommand with no .pkl file argument; wrapping scripts that lose the argument due to shell quoting; automated tooling invoking the CLI with an empty module path.","solutions":["Supply the required positional argument, e.g. `pkl run script.pkl`","Check the command's `--help` to see required arguments","Fix wrapper scripts that drop empty variables representing the argument"],"exampleFix":"// before\npkl run\n// after\npkl run script.pkl","handlingStrategy":"validation","validationCode":"// validate positional args before invoking the CLI\nif (process.argv.length < 2) {\n  console.error('Missing argument \"module\"');\n  process.exit(2);\n}","typeGuard":null,"tryCatchPattern":"try {\n  CliCommandRunner(args).run()\n} catch (e: MissingArgument) {\n  System.err.println(\"${e.argument} is required: pkl run <module.pkl>\")\n  System.exit(2)\n}","preventionTips":["Always include the module path when calling pkl run/eval","Quote variables so empty values are caught by :? expansions","Check CLI wrapper templates after upgrading pkl versions"],"tags":["cli","pkl","missing-argument","picocli"],"backgroundTag":"missing-required-argument","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"}