nodejs/node · error
argument --rm / -j or --keep / -k already set\n
Error message
argument --rm / -j or --keep / -k already set\n
What it means
`-j`/`--rm` (delete the source after success) and `-k`/`--keep` (keep the source) share a single keep/rm toggle and are mutually exclusive. Setting either a second time, or both, is rejected.
Source
Thrown at deps/brotli/c/tools/brotli.c:375
fprintf(stderr, "command already set when parsing -d\n");
return COMMAND_INVALID;
}
command_set = BROTLI_TRUE;
command = COMMAND_DECOMPRESS;
continue;
} else if (c == 'f') {
if (params->force_overwrite) {
fprintf(stderr, "force output overwrite already set\n");
return COMMAND_INVALID;
}
params->force_overwrite = BROTLI_TRUE;
continue;
} else if (c == 'h') {
/* Don't parse further. */
return COMMAND_HELP;
} else if (c == 'j' || c == 'k') {
if (keep_set) {
fprintf(stderr, "argument --rm / -j or --keep / -k already set\n");
return COMMAND_INVALID;
}
keep_set = BROTLI_TRUE;
params->junk_source = TO_BROTLI_BOOL(c == 'j');
continue;
} else if (c == 'n') {
if (!params->copy_stat) {
fprintf(stderr, "argument --no-copy-stat / -n already set\n");
return COMMAND_INVALID;
}
params->copy_stat = BROTLI_FALSE;
continue;
} else if (c == 's') {
if (squash_set) {
fprintf(stderr, "argument --squash / -s already set\n");
return COMMAND_INVALID;
}
squash_set = BROTLI_TRUE;View on GitHub (pinned to 1b2de5e052)
Solutions
- Choose one: keep the source (`-k`) or remove it (`-j`).
- Remove the contradictory flag from your alias/script.
Example fix
// before brotli -j -k file.br # contradictory // after brotli -j file.br # remove source after decompress
Defensive patterns
Strategy: validation
Validate before calling
jk=[a for a in argv if a in ('-j','--rm','-k','--keep') or (a.startswith('-') and not a.startswith('--') and ('j' in a or 'k' in a))]
assert len(jk) <= 1, '--rm/-j and --keep/-k are mutually exclusive' Prevention
- Decide source retention once per invocation.
- Do not combine -j and -k.
When it happens
Trigger: `brotli -j -k file`, `brotli -k -k file`, `brotli -j -j file`, or coalesced `brotli -jk file`.
Common situations: Wanting contradictory behavior (keep AND remove); an alias that sets `-k` plus a user `-j`; wrapper concatenation.
Related errors
- too many options passed
- quality already set
- write to standard output already set
- command already set when parsing -d
- force output overwrite already set\n
AI-assisted analysis of nodejs/node@1b2de5e052 (2026-08-13).
Data as JSON: /api/errors/294e981adb366ffa.
Report an issue: GitHub.