nodejs/node · error

Error creating installation directory: %s\n

Error message

Error creating installation directory: %s\n

What it means

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.

Source

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

#endif

    if (noVersion) {
        return result;
    } else {
        return pkg_createSymLinks(installDir, true);
    }
}

static int32_t pkg_installCommonMode(const char *installDir, const char *fileName) {
    int32_t result = 0;
    char cmd[LARGE_BUFFER_MAX_SIZE] = "";

    if (!T_FileStream_file_exists(installDir)) {
        UErrorCode status = U_ZERO_ERROR;

        uprv_mkdir(installDir, &status);
        if (U_FAILURE(status)) {
            fprintf(stderr, "Error creating installation directory: %s\n", installDir);
            return -1;
        }
    }
#ifndef U_WINDOWS_WITH_MSVC
    snprintf(cmd, sizeof(cmd), "%s %s %s", pkgDataFlags[INSTALL_CMD], fileName, installDir);
#else
    snprintf(cmd, sizeof(cmd), "%s %s %s %s", WIN_INSTALL_CMD, fileName, installDir, WIN_INSTALL_CMD_FLAGS);
#endif

    result = runCommand(cmd);
    if (result != 0) {
        fprintf(stderr, "Failed to install data file with command: %s\n", cmd);
    }

    return result;
}

#ifdef U_WINDOWS_MSVC

View on GitHub (pinned to 1b2de5e052)

Solutions

  1. Create parent directories manually before running pkgdata: 'mkdir -p /path/to/install/dir'.
  2. Verify write permissions on the parent of the install directory.
  3. Ensure the path doesn't conflict with an existing file.
  4. Check the filesystem is mounted read-write.

Example fix

// before: install dir /opt/icu/lib doesn't exist and parent missing
//   pkgdata --install /opt/icu/lib ...
// after: create the full path first
//   mkdir -p /opt/icu/lib && pkgdata --install /opt/icu/lib ...
Defensive patterns

Strategy: validation

Validate before calling

// Before running pkgdata --install, verify the parent dir exists
#include <unistd.h>
#include <sys/stat.h>
#include <libgen.h>

bool canCreateInstallDir(const char* installDir) {
    char* parent = strdup(installDir);
    char* dir = dirname(parent);
    bool ok = access(dir, W_OK) == 0;
    free(parent);
    return ok;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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).

Related errors


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