nodejs/node · warning

setting user failed for [%s]: %s\n

Error message

setting user failed for [%s]: %s\n

What it means

During `CopyStat`, `chown()` failed when trying to set the owner (user ID) of the output file to match the input (gid left at -1, so only the owner changes). Non-fatal warning; the data conversion already completed.

Source

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

    return;
  }
  if (stat(input_path, &statbuf) != 0) {
    return;
  }
  res = CopyTimeStat(&statbuf, output_path);
  res = chmod(output_path, statbuf.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO));
  if (res != 0) {
    fprintf(stderr, "setting access bits failed for [%s]: %s\n",
            PrintablePath(output_path), strerror(errno));
  }
  res = chown(output_path, (uid_t)-1, statbuf.st_gid);
  if (res != 0) {
    fprintf(stderr, "setting group failed for [%s]: %s\n",
            PrintablePath(output_path), strerror(errno));
  }
  res = chown(output_path, statbuf.st_uid, (gid_t)-1);
  if (res != 0) {
    fprintf(stderr, "setting user failed for [%s]: %s\n",
            PrintablePath(output_path), strerror(errno));
  }
}

/* Result ownership is passed to caller.
   |*dictionary_size| is set to resulting buffer size. */
static BROTLI_BOOL ReadDictionary(Context* context, Command command) {
  static const int kMaxDictionarySize =
      BROTLI_MAX_DISTANCE - BROTLI_MAX_BACKWARD_LIMIT(24);
  FILE* f;
  int64_t file_size_64;
  uint8_t* buffer;
  size_t bytes_read;

  if (context->dictionary_path == NULL) return BROTLI_TRUE;
  f = fopen(context->dictionary_path, "rb");
  if (f == NULL) {
    fprintf(stderr, "failed to open dictionary file [%s]: %s\n",

View on GitHub (pinned to 1b2de5e052)

Solutions

  1. Run as root if preserving owner is a hard requirement.
  2. Use `--no-copy-stat` to suppress the ownership copy attempt.
  3. Accept the warning when ownership preservation is not needed.
Defensive patterns

Strategy: fallback

Validate before calling

#include <unistd.h>
#include <stdbool.h>

bool can_set_owner(uid_t target_uid) {
    if (geteuid() == 0) return true; // root
    // Non-root can only chown to themselves (and on Linux, only root can truly change owner)
    return geteuid() == target_uid;
}

Prevention

When it happens

Trigger: The invoking user is not root and not the current owner of the file (EPERM on most Unix systems — only root or the file owner can change the owner, and even the owner can only change to themselves on Linux); NFS root-squash; output deleted before chown.

Common situations: Running brotli as a non-root service account and trying to preserve ownership from files owned by root or another user; CI pipelines running as a generic user.

Related errors


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