{"record":{"id":"572b5c06bca79ee9","repo":"nodejs/node","slug":"unable-to-create-map-file-s-n","errorCode":null,"errorMessage":"Unable to create map file: %s.\\n","messagePattern":"Unable to create map file: (.+?)\\.\\\\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"deps/icu-small/source/tools/pkgdata/pkgdata.cpp","lineNumber":1988,"sourceCode":"                }\n            }\n\n            tmpbuffer[index++] = flag[i];\n\n            if (flag[i] == 0) {\n                break;\n            }\n        }\n\n        uprv_memset(flag, 0, length);\n        uprv_strcpy(flag, tmpbuffer);\n\n        uprv_strcpy(mapFile, o->shortName);\n        uprv_strcat(mapFile, MAP_FILE_EXT);\n\n        f = T_FileStream_open(mapFile, \"w\");\n        if (f == nullptr) {\n            fprintf(stderr,\"Unable to create map file: %s.\\n\", mapFile);\n            return nullptr;\n        } else {\n            snprintf(tmpbuffer, sizeof(tmpbuffer), \"%s%s \", o->entryName, UDATA_CMN_INTERMEDIATE_SUFFIX);\n    \n            T_FileStream_writeLine(f, tmpbuffer);\n    \n            T_FileStream_close(f);\n        }\n    }\n#elif U_PLATFORM == U_PF_CYGWIN || U_PLATFORM == U_PF_MINGW\n    /* Cygwin needs to change flag options. */\n    char *flag = nullptr;\n    int32_t length = 0;\n\n    flag = pkgDataFlags[GENLIB];\n    length = static_cast<int32_t>(uprv_strlen(pkgDataFlags[GENLIB]));\n\n    int32_t position = length - 1;","sourceCodeStart":1970,"sourceCodeEnd":2006,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/deps/icu-small/source/tools/pkgdata/pkgdata.cpp#L1970-L2006","documentation":"pkgdata cannot open the generated .map (linker map) file for writing. The filename is built from o->shortName + MAP_FILE_EXT and opened with T_FileStream_open(...,\"w\"). A nullptr return means the filesystem refused the create — typically a permission denial, a read-only build directory, a full disk, or an invalid shortName producing an illegal filename. The tool returns nullptr from the calling function, aborting map-file generation for that library mode.","triggerScenarios":"Reached only in the branch that writes a map file (the non-Cygwin/Mingw path guarded by the #elif above). T_FileStream_open(mapFile,\"w\") returns nullptr. Triggers when the CWD or output dir is not writable, when o->shortName contains path separators/illegal chars, or when MAP_FILE_EXT resolves to a name that already exists as a directory.","commonSituations":"Building ICU data into a directory the build user cannot write (e.g. make install running as non-root into /usr), NFS-mounted read-only source trees, out-of-disk conditions during a parallel build, or a shortName set from a package name containing a slash.","solutions":["Verify the working directory is writable: touch the build dir as the build user.","Run the build with adequate disk space (df -h .).","Check that -O/--shortName (or the ICU_DATA short name) contains no path separators or illegal filename characters.","Ensure no directory named <shortName>.map already exists in the output location."],"exampleFix":"// before: build into read-only tree\nmake install  # runs as user without write perms\n\n// after: write into a user-writable staging dir\nmkdir -p /tmp/icu-stage && make DESTDIR=/tmp/icu-stage install","handlingStrategy":"validation","validationCode":"// Validate the output directory is writable and the map filename is legal before invoking pkgdata.\n#include <sys/stat.h>\n#include <unistd.h>\n#include <string.h>\n\nbool canWriteMapFile(const char *outdir, const char *shortName) {\n    if (access(outdir, W_OK | X_OK) != 0) return false;     // need write+search on dir\n    struct stat st;\n    char path[PATH_MAX];\n    snprintf(path, sizeof(path), \"%s/%s.map\", outdir, shortName);\n    if (stat(path, &st) == 0 && S_ISDIR(st.st_mode)) return false; // name collides with a dir\n    for (const char *p = shortName; *p; ++p)\n        if (*p == '/' || *p == '\\\\') return false;          // shortName must be a bare name\n    return true;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run pkgdata from a user-writable directory.","Never embed path separators in the package short name.","Confirm disk space before large data builds.","Ensure no directory shares the <shortName>.map filename."],"tags":["icu","pkgdata","file-io","build-tool","filesystem","permissions"],"backgroundTag":null,"analyzedSha":"1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e","analyzedAt":"2026-08-13T00:53:24.642Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}