{"record":{"id":"5cf32f8d7943c3c3","repo":"nodejs/node","slug":"error-creating-installation-directory-s-n","errorCode":null,"errorMessage":"Error creating installation directory: %s\\n","messagePattern":"Error creating installation directory: (.+?)\\\\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"deps/icu-small/source/tools/pkgdata/pkgdata.cpp","lineNumber":1226,"sourceCode":"#endif\n\n    if (noVersion) {\n        return result;\n    } else {\n        return pkg_createSymLinks(installDir, true);\n    }\n}\n\nstatic int32_t pkg_installCommonMode(const char *installDir, const char *fileName) {\n    int32_t result = 0;\n    char cmd[LARGE_BUFFER_MAX_SIZE] = \"\";\n\n    if (!T_FileStream_file_exists(installDir)) {\n        UErrorCode status = U_ZERO_ERROR;\n\n        uprv_mkdir(installDir, &status);\n        if (U_FAILURE(status)) {\n            fprintf(stderr, \"Error creating installation directory: %s\\n\", installDir);\n            return -1;\n        }\n    }\n#ifndef U_WINDOWS_WITH_MSVC\n    snprintf(cmd, sizeof(cmd), \"%s %s %s\", pkgDataFlags[INSTALL_CMD], fileName, installDir);\n#else\n    snprintf(cmd, sizeof(cmd), \"%s %s %s %s\", WIN_INSTALL_CMD, fileName, installDir, WIN_INSTALL_CMD_FLAGS);\n#endif\n\n    result = runCommand(cmd);\n    if (result != 0) {\n        fprintf(stderr, \"Failed to install data file with command: %s\\n\", cmd);\n    }\n\n    return result;\n}\n\n#ifdef U_WINDOWS_MSVC","sourceCodeStart":1208,"sourceCodeEnd":1244,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/deps/icu-small/source/tools/pkgdata/pkgdata.cpp#L1208-L1244","documentation":"uprv_mkdir() returned U_FAILURE when trying to create the installation directory. Called from pkg_installCommonMode() (line 1217) when the install directory doesn't exist (T_FileStream_file_exists returns false). The directory creation failed, and the tool exits with -1 before attempting any file copy.","triggerScenarios":"The install directory path passed to pkg_installCommonMode doesn't exist and uprv_mkdir() failed to create it. U_FAILURE(status) is true after the mkdir call. The status code indicates the specific filesystem error.","commonSituations":"Parent directories don't exist (uprv_mkdir doesn't create parents recursively); permission denied on the parent directory; invalid path (contains invalid characters or is too long); read-only filesystem; path points to an existing file (not a directory).","solutions":["Create parent directories manually before running pkgdata: 'mkdir -p /path/to/install/dir'.","Verify write permissions on the parent of the install directory.","Ensure the path doesn't conflict with an existing file.","Check the filesystem is mounted read-write."],"exampleFix":"// before: install dir /opt/icu/lib doesn't exist and parent missing\n//   pkgdata --install /opt/icu/lib ...\n// after: create the full path first\n//   mkdir -p /opt/icu/lib && pkgdata --install /opt/icu/lib ...","handlingStrategy":"validation","validationCode":"// Before running pkgdata --install, verify the parent dir exists\n#include <unistd.h>\n#include <sys/stat.h>\n#include <libgen.h>\n\nbool canCreateInstallDir(const char* installDir) {\n    char* parent = strdup(installDir);\n    char* dir = dirname(parent);\n    bool ok = access(dir, W_OK) == 0;\n    free(parent);\n    return ok;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Create the full install directory path with 'mkdir -p' before running pkgdata.","Verify write permissions on the parent directory.","Ensure the path doesn't conflict with an existing file."],"tags":["icu","pkgdata","mkdir","install","filesystem","permissions","build-tool"],"backgroundTag":null,"analyzedSha":"1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e","analyzedAt":"2026-08-13T00:53:24.642Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}