remix-run/remix · error · UsageError
RMX_UNEXPECTED_ARGUMENT
RMX_UNEXPECTED_ARGUMENT
Error message
Unexpected extra argument: ${argument} What it means
Thrown when a positional argument appears after the command has already collected its maximum allowed number of positionals (`options.maxPositionals`). Extra positionals indicate the user passed more arguments than the command accepts.
Source
Thrown at packages/cli/src/lib/parse-args.ts:91
continue
}
let next = argv[index + 1]
if (next == null || next.length === 0 || next.startsWith('-')) {
throw missingOptionValue(flag)
}
values[resolved.key] = next as ParsedArgsValues<definitions>[typeof resolved.key]
index += 1
continue
}
if (arg.startsWith('-')) {
throw unknownArgument(arg)
}
if (options.maxPositionals != null && positionals.length >= options.maxPositionals) {
throw unexpectedExtraArgument(arg)
}
positionals.push(arg)
}
return { options: values, positionals }
}
View on GitHub (pinned to 9696913134)
Solutions
- Remove the extra positional argument(s)
- Quote shell globs so they are not expanded into multiple positionals
- Check the command usage/help for how many positionals it accepts
Example fix
# before remix generate route a b c # after remix generate route a
Defensive patterns
Strategy: validation
Validate before calling
const MAX = 1
const positionals = argv.filter((a) => !a.startsWith('-'))
if (positionals.length > MAX) throw new Error(`Expected at most ${MAX} positional argument(s)`) Try / catch
catch (error) {
if (error instanceof Error && error.code === 'RMX_UNEXPECTED_ARGUMENT') {
// print usage
}
throw error
} Prevention
- Quote globs passed as single arguments
- Validate argument count before invoking the command
When it happens
Trigger: Passing more positional arguments than the command's `maxPositionals` limit, e.g. a third directory argument to a command accepting two.
Common situations: Unquoted shell globs expanding to multiple paths, or misunderstanding a command's argument count.
Related errors
- RMX_UNEXPECTED_ARGUMENT
- --config requires a value.
- Unknown command: assets ${command}
- `remix assets inspect` requires a URL or file path.
- Unknown command: db ${command}
AI-assisted analysis of remix-run/remix@9696913134 (2026-08-27).
Data as JSON: /api/errors/7e31275ca941761b.
Report an issue: GitHub.