{"record":{"id":"5a7edf9ba63364b8","repo":"nodejs/node","slug":"unable-to-remove-old-dat-file-s","errorCode":null,"errorMessage":"Unable to remove old dat file: %s\n","messagePattern":"Unable to remove old dat file: (.+?)\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"deps/icu-small/source/tools/pkgdata/pkgdata.cpp","lineNumber":636,"sourceCode":"          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                }\n\n                result = rename(datFileNamePath, targetFileNamePath);\n\n                if (o->verbose) {\n                    fprintf(stdout, \"# Moving package file to %s ..\\n\",\n                            targetFileNamePath);\n                }\n                if (result != 0) {\n                    fprintf(\n                            stderr,\n                            \"Unable to move dat file (%s) to target location (%s).\\n\",\n                            datFileNamePath, targetFileNamePath);\n                    return result;\n                }","sourceCodeStart":618,"sourceCodeEnd":654,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/deps/icu-small/source/tools/pkgdata/pkgdata.cpp#L618-L654","documentation":"In common mode, before renaming the freshly written .dat into the target location, pkgdata removes any pre-existing target file. If remove() returns non-zero it prints the target path and returns that result code. The new file was written successfully; only the replace-in-place step failed.","triggerScenarios":"The target .dat exists but is read-only, held open by another process, or the directory does not permit deletion.","commonSituations":"Previous build artifact locked by an IDE/antivirus; restrictive permissions on the target dir; NFS stale file handles.","solutions":["Delete the stale target .dat manually before rebuilding.","Close any process holding the file (IDE, antivirus, file manager).","Check that the target directory permits delete by the build user."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"# bash: pre-clean a writable target so remove() won't be needed mid-run\nif [ -e \"$TARGET_DAT\" ] && [ ! -w \"$TARGET_DAT\" ]; then\n  echo \"target not removable: $TARGET_DAT\" >&2; exit 2\nfi\nrm -f \"$TARGET_DAT\" 2>/dev/null || true","typeGuard":null,"tryCatchPattern":"# if replace-in-place fails, clean up and retry once\npkgdata \"$@\" || { rm -f \"$TARGET_DAT\" && pkgdata \"$@\"; exit $?; }","preventionTips":["Delete stale target .dat files at the start of each clean build.","Close IDEs/antivirus that may lock build artifacts on Windows."],"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"}