nodejs/node · error

command already set when parsing --decompress\n

Error message

command already set when parsing --decompress\n

What it means

`--decompress` sets the operation mode (`command = COMMAND_DECOMPRESS`) and is guarded by the shared `command_set` latch, which is also flipped by `-d`, `-z` (compress), `-t` (test), and other mode selectors. Specifying two different (or duplicate) commands is rejected so the intended action is unambiguous.

Source

Thrown at deps/brotli/c/tools/brotli.c:526

      arg = &arg[2];
      if (strcmp("best", arg) == 0) {
        if (quality_set) {
          fprintf(stderr, "quality already set\n");
          return COMMAND_INVALID;
        }
        quality_set = BROTLI_TRUE;
        params->quality = 11;
      } else if (strcmp("concatenated", arg) == 0) {
        if (concatenated_set) {
          fprintf(stderr, "argument -K / --concatenated already set\n");
          return COMMAND_INVALID;
        }
        concatenated_set = BROTLI_TRUE;
        params->allow_concatenated = BROTLI_TRUE;
        continue;
      } else if (strcmp("decompress", arg) == 0) {
        if (command_set) {
          fprintf(stderr, "command already set when parsing --decompress\n");
          return COMMAND_INVALID;
        }
        command_set = BROTLI_TRUE;
        command = COMMAND_DECOMPRESS;
      } else if (strcmp("force", arg) == 0) {
        if (params->force_overwrite) {
          fprintf(stderr, "force output overwrite already set\n");
          return COMMAND_INVALID;
        }
        params->force_overwrite = BROTLI_TRUE;
      } else if (strcmp("help", arg) == 0) {
        /* Don't parse further. */
        return COMMAND_HELP;
      } else if (strcmp("keep", arg) == 0) {
        if (keep_set) {
          fprintf(stderr, "argument --rm / -j or --keep / -k already set\n");
          return COMMAND_INVALID;
        }

View on GitHub (pinned to 1b2de5e052)

Solutions

  1. Pass exactly one mode flag (`-d`, `-z`, `-t`, `--decompress`, etc.).
  2. If relying on a program-name alias for the mode, do not also pass an explicit mode flag.
  3. Inspect the resolved argv (print it) to find the duplicate source.

Example fix

# before
brotli -d --decompress in.br
# after
brotli -d in.br
Defensive patterns

Strategy: validation

Validate before calling

# bash: at most one command/mode flag (covers aliases)
m=$(printf '%s\n' "$@" | grep -cE '^(-d|-z|-t|--compress|--decompress|--test.*)$')
if [ "$m" -gt 1 ]; then echo "multiple command/mode flags" >&2; exit 2; fi
brotli "$@"

Try / catch

# bash
if ! brotli "$@"; then rc=$?; echo "brotli exit $rc; check for duplicate command flag" >&2; exit "$rc"; fi

Prevention

When it happens

Trigger: `brotli -d --decompress in`, `brotli -z --decompress in`, `brotli -t --decompress in`, or `brotli --decompress --decompress in`.

Common situations: Invoking brotli through a symlink alias (e.g. `unbrotli`) that already implies decompress, plus an explicit `--decompress`; scripts layering mode flags; calling the binary as both `brotli -d` and adding `--decompress` defensively.

Related errors


AI-assisted analysis of nodejs/node@1b2de5e052 (2026-08-13). Data as JSON: /api/errors/2a3ab8ee70305fab. Report an issue: GitHub.