{"record":{"id":"f559d57b2d83f399","repo":"nodejs/node","slug":"error-writing-package-dat-file","errorCode":null,"errorMessage":"Error writing package dat file.\n","messagePattern":"Error writing package dat file\\.\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"deps/icu-small/source/tools/pkgdata/pkgdata.cpp","lineNumber":622,"sourceCode":"        uprv_strcpy(targetDir, o->targetDir);\n        uprv_strcat(targetDir, PKGDATA_FILE_SEP_STRING);\n\n        uprv_strcpy(tmpDir, o->tmpDir);\n        uprv_strcat(tmpDir, PKGDATA_FILE_SEP_STRING);\n\n        uprv_strcpy(datFileNamePath, tmpDir);\n\n        uprv_strcpy(datFileName, o->shortName);\n        uprv_strcat(datFileName, UDATA_CMN_SUFFIX);\n\n        uprv_strcat(datFileNamePath, datFileName);\n\n        if(o->verbose) {\n          fprintf(stdout, \"# Writing package file %s ..\\n\", datFileNamePath);\n        }\n        result = writePackageDatFile(datFileNamePath, o->comment, o->srcDir, o->fileListFiles->str, nullptr, U_CHARSET_FAMILY ? 'e' :  U_IS_BIG_ENDIAN ? 'b' : 'l');\n        if (result != 0) {\n            fprintf(stderr,\"Error writing package dat file.\\n\");\n            return result;\n        }\n\n        if (IN_COMMON_MODE(mode)) {\n            char targetFileNamePath[LARGE_BUFFER_MAX_SIZE] = \"\";\n\n            uprv_strcpy(targetFileNamePath, targetDir);\n            uprv_strcat(targetFileNamePath, datFileName);\n\n            /* Move the dat file created to the target directory. */\n            if (uprv_strcmp(datFileNamePath, targetFileNamePath) != 0) {\n                if (T_FileStream_file_exists(targetFileNamePath)) {\n                    if ((result = remove(targetFileNamePath)) != 0) {\n                        fprintf(stderr, \"Unable to remove old dat file: %s\\n\",\n                                targetFileNamePath);\n                        return result;\n                    }\n                }","sourceCodeStart":604,"sourceCodeEnd":640,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/deps/icu-small/source/tools/pkgdata/pkgdata.cpp#L604-L640","documentation":"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.","triggerScenarios":"Output directory missing or not writable, disk full, path too long, or permission denied during the write.","commonSituations":"Target directory not created yet; read-only build output; out of disk space; antivirus locking the file on Windows.","solutions":["Ensure the output directory exists and is writable by the build user.","Free disk space on the output volume.","Run pkgdata with --verbose to see the exact datFileNamePath being written, then verify that location."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"# bash: writable output dir + free disk before writing the .dat\nOUT_DIR=\"$(dirname \"$OUT_DAT\")\"\n[ -w \"$OUT_DIR\" ] || { echo \"output dir not writable: $OUT_DIR\" >&2; exit 2; }\ndfree=$(df -k --output=avail \"$OUT_DIR\" | tail -1)\n[ \"$dfree\" -gt 10240 ] || { echo \"low disk on $OUT_DIR\" >&2; exit 2; }","typeGuard":null,"tryCatchPattern":"# treat a write failure as retryable after cleanup\npkgdata \"$@\" || { rc=$?; rm -f \"$OUT_DAT\".tmp; pkgdata \"$@\"; exit $?; }","preventionTips":["Create and chmod the output directory in the build setup step.","Monitor free disk on the output volume in CI."],"tags":["icu","pkgdata","filesystem","io"],"backgroundTag":null,"analyzedSha":"1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e","analyzedAt":"2026-08-13T00:53:24.642Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}