39.4 Exit code 2: invalid command-line usage
What you will learn
- Diagnose parser and command-grammar errors
- Handle quoted mini-languages and conflicting modes
- Capture early failures without a transcript
Prerequisites: Chapter 36 exit-code reference, Chapter 38 output completion, and the Chapter 39 overview.
This page describes nlmx 4.16.2. Troubleshooting must preserve the failed attempt: keep its exact command, working directory, log, resolved settings, input/model identities, partial outputs, and process exit code. Correct one causal condition at a time and compare the new evidence with the failed run. Never convert a nonzero exit into success in a wrapper, and never interpret exit 0 as scientific acceptance without the command-native verdict.
Exit 2 means nlmx could not accept the invocation as a valid request. Common causes are a misspelled command/option, a missing option value, an unexpected positional argument, a malformed numeric/list/KEY=VALUE expression, mutually exclusive input modes, or an option/backend combination refused by policy. Parser errors occur before normal logging, so shell capture may be the only transcript.
Start with nlmx <command> --help, not a web snippet or another version's manual. Copy the Usage line and rebuild the smallest invocation. Confirm the executable actually resolved by the shell (Get-Command nlmx on PowerShell). Quote paths containing spaces and quote whole expressions such as --test "CL~WT=0.75"; do not insert shell metacharacters from untrusted text.
Distinguish parser-level acceptance from command-specific usage. The shared CLI is broad, but a command may reject an otherwise recognized option or combination. For example, report accepts one Markdown source—not a file plus --markdown; covariate analysis requires a configuration or explicit relationship scope; Maxson server URLs and remote access are policy constrained.
When a script receives code 2, do not retry unchanged. Emit the exact argv array, executable/version, and stderr; mark the job as configuration failure. Never “fix” it by dropping an unknown option automatically, because the dropped option may carry the scientific intent. A human or versioned adapter must translate it.
After correction, verify the command banner/log records the intended values. If the correction involved quoting, print the final argument vector safely; a visually similar command string may be tokenized differently by PowerShell, cmd.exe, or a POSIX shell.
Page checklist
- Did you retain the exact exit code, stage, message, hint, log, and partial output?
- Did you identify one causal layer before changing anything?
- Is the recovery a new, traceable attempt with the same intended estimand?
- Did you check command-native and scientific acceptance after process completion?
Navigation
See the previous page, next page, and complete error reference.