nodejs/node · warning

Unable to get stats from file: %s or %s\n

Error message

Unable to get stats from file: %s or %s\n

What it means

In whichFileModTimeIsLater, the stat() calls for one or both files failed, so their mtimes cannot be compared. The function prints both paths, sets result=-1, and returns -1. Callers treat a negative result as 'cannot determine', typically forcing a rebuild of the target.

Source

Thrown at deps/icu-small/source/tools/toolutil/filetools.cpp:127

    int32_t result = 0;
    struct stat stbuf1, stbuf2;

    if (stat(file1, &stbuf1) == 0 && stat(file2, &stbuf2) == 0) {
        time_t modtime1, modtime2;
        double diff;

        modtime1 = stbuf1.st_mtime;
        modtime2 = stbuf2.st_mtime;

        diff = difftime(modtime1, modtime2);
        if (diff < 0.0) {
            result = 2;
        } else if (diff > 0.0) {
            result = 1;
        }

    } else {
        fprintf(stderr, "Unable to get stats from file: %s or %s\n", file1, file2);
        result = -1;
    }

    return result;
}

/* Swap the file separater character given with the new one in the file path. */
U_CAPI void U_EXPORT2
swapFileSepChar(char *filePath, const char oldFileSepChar, const char newFileSepChar) {
    for (int32_t i = 0, length = static_cast<int32_t>(uprv_strlen(filePath)); i < length; i++) {
        filePath[i] = (filePath[i] == oldFileSepChar ) ? newFileSepChar : filePath[i];
    }
}

View on GitHub (pinned to 1b2de5e052)

Solutions

  1. Confirm both files exist: ls -l file1 file2.
  2. Check traverse permission on all parent directories of both paths.
  3. If the target legitimately does not exist yet, expect -1 and let the build create it.
  4. Avoid symlink loops or replace broken symlinks.

Example fix

# before: target file does not exist yet
stat('out.dat') -> ENOENT  -> result -1

# after: normal on first build; build proceeds and creates out.dat
make  # regenerates out.dat; subsequent compares succeed
Defensive patterns

Strategy: validation

Validate before calling

// stat both files first; expect -1 on first build (target absent) but not for permission errors.
#include <sys/stat.h>
int canCompareMtimes(const char *a, const char *b) {
    struct stat sa, sb;
    if (stat(a, &sa) != 0) return -1;
    if (stat(b, &sb) != 0) return -1;
    return 0;
}

Prevention

When it happens

Trigger: stat() fails on file1 or file2 — ENOENT (file missing), EACCES (no traverse permission on a parent dir), ENAMETOOLONG, or ENOTDIR. The else-branch fires whenever the prior stat succeeded check is false.

Common situations: Comparing mtimes against a target that has not been generated yet (normal on first build); files on a filesystem that does not support mtime; permission errors on parent directories; symlink loops.

Related errors


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