nodejs/node · error

Error writing package dat file.

Error message

Error writing package dat file.

What it means

writePackageDatFile() returned non-zero while emitting the assembled .dat. pkgdata prints the generic failure and propagates that result code. The error originates in the file write (I/O), not in option parsing — by this point all arguments were accepted.

Source

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

        uprv_strcpy(targetDir, o->targetDir);
        uprv_strcat(targetDir, PKGDATA_FILE_SEP_STRING);

        uprv_strcpy(tmpDir, o->tmpDir);
        uprv_strcat(tmpDir, PKGDATA_FILE_SEP_STRING);

        uprv_strcpy(datFileNamePath, tmpDir);

        uprv_strcpy(datFileName, o->shortName);
        uprv_strcat(datFileName, UDATA_CMN_SUFFIX);

        uprv_strcat(datFileNamePath, datFileName);

        if(o->verbose) {
          fprintf(stdout, "# Writing package file %s ..\n", datFileNamePath);
        }
        result = writePackageDatFile(datFileNamePath, o->comment, o->srcDir, o->fileListFiles->str, nullptr, U_CHARSET_FAMILY ? 'e' :  U_IS_BIG_ENDIAN ? 'b' : 'l');
        if (result != 0) {
            fprintf(stderr,"Error writing package dat file.\n");
            return result;
        }

        if (IN_COMMON_MODE(mode)) {
            char targetFileNamePath[LARGE_BUFFER_MAX_SIZE] = "";

            uprv_strcpy(targetFileNamePath, targetDir);
            uprv_strcat(targetFileNamePath, datFileName);

            /* Move the dat file created to the target directory. */
            if (uprv_strcmp(datFileNamePath, targetFileNamePath) != 0) {
                if (T_FileStream_file_exists(targetFileNamePath)) {
                    if ((result = remove(targetFileNamePath)) != 0) {
                        fprintf(stderr, "Unable to remove old dat file: %s\n",
                                targetFileNamePath);
                        return result;
                    }
                }

View on GitHub (pinned to 1b2de5e052)

Solutions

  1. Ensure the output directory exists and is writable by the build user.
  2. Free disk space on the output volume.
  3. Run pkgdata with --verbose to see the exact datFileNamePath being written, then verify that location.
Defensive patterns

Strategy: validation

Validate before calling

# bash: writable output dir + free disk before writing the .dat
OUT_DIR="$(dirname "$OUT_DAT")"
[ -w "$OUT_DIR" ] || { echo "output dir not writable: $OUT_DIR" >&2; exit 2; }
dfree=$(df -k --output=avail "$OUT_DIR" | tail -1)
[ "$dfree" -gt 10240 ] || { echo "low disk on $OUT_DIR" >&2; exit 2; }

Try / catch

# treat a write failure as retryable after cleanup
pkgdata "$@" || { rc=$?; rm -f "$OUT_DAT".tmp; pkgdata "$@"; exit $?; }

Prevention

When it happens

Trigger: Output directory missing or not writable, disk full, path too long, or permission denied during the write.

Common situations: Target directory not created yet; read-only build output; out of disk space; antivirus locking the file on Windows.

Related errors


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