nodejs/node · warning

## ERR: Path too long [%d chars]: %s\n

Error message

## ERR: Path too long [%d chars]: %s\n

What it means

In the directory-extraction helper (pkgtypes.c), the directory portion of a path (rPtr-strAlias) is compared against UPRV_LENGTHOF(aBuf); if it meets or exceeds that fixed buffer size the path is rejected as too long. The function prints the buffer size and the offending path and returns the list unchanged (no directory added). This is non-fatal — the entry is simply not added to the directory list.

Source

Thrown at deps/icu-small/source/tools/pkgdata/pkgtypes.c:230

CharList *pkg_appendUniqueDirToList(CharList *l, CharList** end, const char *strAlias) {
    char aBuf[1024];
    char *rPtr;
    rPtr = uprv_strrchr(strAlias, U_FILE_SEP_CHAR);
#if (U_FILE_SEP_CHAR != U_FILE_ALT_SEP_CHAR)
    {
        char *aPtr = uprv_strrchr(strAlias, U_FILE_ALT_SEP_CHAR);
        if(!rPtr || /* regular char wasn't found or.. */
            (aPtr && (aPtr > rPtr)))
        { /* alt ptr exists and is to the right of r ptr */
            rPtr = aPtr; /* may copy NULL which is OK */
        }
    }
#endif
    if(!rPtr) {
        return l; /* no dir path */
    }
    if((rPtr-strAlias) >= UPRV_LENGTHOF(aBuf)) {
        fprintf(stderr, "## ERR: Path too long [%d chars]: %s\n", (int)sizeof(aBuf), strAlias);
        return l;
    }
    strncpy(aBuf, strAlias,(rPtr-strAlias));
    aBuf[rPtr-strAlias]=0;  /* no trailing slash */
    convertToNativePathSeparators(aBuf);

    if(!pkg_listContains(l, aBuf)) {
        return pkg_appendToList(l, end, uprv_strdup(aBuf));
    } else {
        return l; /* already found */
    }
}

#if 0
static CharList *
pkg_appendFromStrings(CharList *l, CharList** end, const char *s, int32_t len)
{
  CharList *endptr = NULL;

View on GitHub (pinned to 1b2de5e052)

Solutions

  1. Shorten the directory prefix of the offending path (fewer/shorter path components).
  2. Flatten the resource tree layout where possible.
  3. Move the build root closer to the filesystem root to reduce absolute path length.
  4. Regenerate the file list to avoid embedding long common prefixes.

Example fix

# before: directory prefix >= aBuf length
/opt/very/deep/.../icu/translit/locale/path/file.res

# after: shorten the tree
/icu/translit/locale/path/file.res
Defensive patterns

Strategy: validation

Validate before calling

// Warn (non-fatal) when a path's directory prefix is too long for aBuf.
#include <string.h>
#include <libgen.h>
bool dirPrefixFits(const char *path, size_t aBufSize) {
    char tmp[4096]; strncpy(tmp, path, sizeof(tmp)-1); tmp[sizeof(tmp)-1]=0;
    char *d = dirname(tmp);
    return strlen(d) < aBufSize;
}

Prevention

When it happens

Trigger: A file path whose directory prefix is at least as long as aBuf. The directory is then not recorded in the deduplicated directory list used for packaging.

Common situations: Very deep ICU data trees (translit%/locale%/long subpaths); absolute paths embedded by a build script; pathological locale names.

Related errors


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