nodejs/node · error

%s: Error: don't specify an encoding (-e) when writing to st

Error message

%s: Error: don't specify an encoding (-e) when writing to stdout (-c).\n

What it means

derb treats -c/--to-stdout and -e/--encoding as mutually exclusive: writing raw bytes to stdout is incompatible with a user-specified output encoding. If both doesOccur, it prints this error and returns 3 before doing any work.

Source

Thrown at deps/icu-small/source/tools/genrb/derb.cpp:136

            " bundle ...\n", argc < 0 ? 'u' : 'U',
            pname);
        return argc<0 ? U_ILLEGAL_ARGUMENT_ERROR : U_ZERO_ERROR;
    }

    if(options[10].doesOccur) {
        fprintf(stderr,
                "%s version %s (ICU version %s).\n"
                "%s\n",
                pname, DERB_VERSION, U_ICU_VERSION, U_COPYRIGHT_STRING);
        return U_ZERO_ERROR;
    }
    if(options[2].doesOccur) {
        encoding = options[2].value;
    }

    if (options[3].doesOccur) {
      if(options[2].doesOccur) {
        fprintf(stderr, "%s: Error: don't specify an encoding (-e) when writing to stdout (-c).\n", pname);
        return 3;
      }
      tostdout = 1;
    }

    if(options[4].doesOccur) {
        opt_truncate = true;
        if(options[4].value != nullptr) {
            truncsize = atoi(options[4].value); /* user defined printable size */
        } else {
            truncsize = DERB_DEFAULT_TRUNC; /* we'll use default omitting size */
        }
    } else {
        opt_truncate = false;
    }

    if(options[5].doesOccur) {
        verbose = true;

View on GitHub (pinned to 1b2de5e052)

Solutions

  1. Drop -e when using -c (let derb write the native/raw bytes to stdout).
  2. Or drop -c and write to a file (-d destdir) so -e can control the encoding of that file.
  3. If you need a specific encoding on stdout, encode the bundle to a file with -e and then `cat`/transcode that file separately.

Example fix

# before
derb -c -e UTF-8 root.res

# after
derb -c root.res          # raw bytes to stdout
# or
derb -e UTF-8 -d out root.res   # encoded file, no stdout
Defensive patterns

Strategy: validation

Validate before calling

// enforce mutual exclusion of -c and -e
if '-c' in argv and ('-e' in argv or '--encoding' in argv):
    raise SystemExit('derb: -c/--to-stdout and -e/--encoding are mutually exclusive')

Prevention

When it happens

Trigger: options[3] (to-stdout, -c) and options[2] (encoding, -e) are both present on the command line. derb detects the combination and aborts.

Common situations: Piping derb output through another tool (-c) while also trying to force a specific encoding (-e); copy-pasting a genrb command line that included -e and adding -c; shell alias that always sets -e.

Related errors


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