nodejs/node · error

%s: Unable to locate pkgdata.inc. Unable to parse the result

Error message

%s: Unable to locate pkgdata.inc. Unable to parse the results of '%s'. Check paths or use the -O option to specify the path to pkgdata.inc.\n

What it means

pkg_getPkgDataPath successfully ran a probe command but the captured buffer is empty after stripping trailing newlines/spaces, meaning the command returned no usable directory. The function prints which probe (pkgconfigCmd or icuconfigCmd depending on pkgconfigIsValid) failed to parse and returns -1. It suggests the -O option to specify pkgdata.inc manually.

Source

Thrown at deps/icu-small/source/tools/pkgdata/pkgdata.cpp:2201

    if (!getPkgDataPath(pkgconfigCmd, verbose, buf, UPRV_LENGTHOF(buf))) {
        if (!getPkgDataPath(icuconfigCmd, verbose, buf, UPRV_LENGTHOF(buf))) {
            fprintf(stderr, "%s: icu-config not found. Fix PATH or specify -O option\n", progname);
            return -1;
        }

        pkgconfigIsValid = false;
    }

    for (int32_t length = strlen(buf) - 1; length >= 0; length--) {
        if (buf[length] == '\n' || buf[length] == ' ') {
            buf[length] = 0;
        } else {
            break;
        }
    }

    if (!*buf) {
        fprintf(stderr, "%s: Unable to locate pkgdata.inc. Unable to parse the results of '%s'. Check paths or use the -O option to specify the path to pkgdata.inc.\n", progname, pkgconfigIsValid ? pkgconfigCmd : icuconfigCmd);
        return -1;
    }

    if (pkgconfigIsValid) {
        uprv_strcat(buf, U_FILE_SEP_STRING);
        uprv_strcat(buf, pkgdata);
    }

    buf[strlen(buf)] = 0;

    option->value = buf;
    option->doesOccur = true;

    return 0;
#else
    return -1;
#endif
}

View on GitHub (pinned to 1b2de5e052)

Solutions

  1. Manually run the shown command to see its actual output and fix the install so it emits a real directory.
  2. Reinstall ICU so 'pkg-config --variable=pkglibdir icu-uc' returns the lib dir.
  3. Bypass detection with the -O option pointing at pkgdata.inc.
  4. Verify the ICU .pc file is well-formed (grep pkglibdir icu-uc.pc).

Example fix

# before: empty pkglibdir variable
$ pkg-config --variable=pkglibdir icu-uc
(prints nothing)

# after: reinstall so variable is set, or use -O
pkgdata -O /opt/icu/lib/icu/pkgdata.inc -p mypkg
Defensive patterns

Strategy: validation

Validate before calling

# Verify the probe returns a non-empty, non-whitespace directory.
out=$(pkg-config --variable=pkglibdir icu-uc 2>/dev/null)
[ -z "$out" ] && out=$(icu-config --incpkgdatafile 2>/dev/null)
case "$out" in *[![:space:]]*) : ;; *) echo "empty probe result; use -O"; exit 1 ;; esac

Prevention

When it happens

Trigger: The probe command ran (popen succeeded, fread returned bytes) but output was only whitespace/newlines, or the variable queried was empty — e.g. pkg-config found icu-uc but pkglibdir is unset, or icu-config printed a blank line.

Common situations: A malformed or partial ICU installation where the .pc file lacks the pkglibdir variable; icu-config shimmed by a wrapper that emits nothing; ICU installed to a path containing only spaces/newlines.

Understand the failure class

Related errors


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