nodejs/node · error

couldn't open file %s

Error message

couldn't open file %s

What it means

During collation rule import (GenrbImporter::getRules path), genrb attempts to open a referenced resource file via ucbuf_open and receives U_FILE_ACCESS_ERROR. This specific path handles importing collation tailoring rules from external files. The file could not be opened or read at all — it does not exist or is inaccessible.

Source

Thrown at deps/icu-small/source/tools/genrb/parse.cpp:763

             * user should use
             * genrb -s. icu/data  --- start from CWD and look in icu/data dir
             */
            openFileName.append(inputDir, dirlen, errorCode);
            if(inputDir[dirlen-1] != U_FILE_SEP_CHAR) {
                openFileName.append(U_FILE_SEP_CHAR, errorCode);
            }
        }
    }
    openFileName.append(filename, errorCode);
    if(U_FAILURE(errorCode)) {
        return;
    }
    // printf("GenrbImporter::getRules(%s, %s) reads %s\n", localeID, collationType, openFileName.data());
    const char* cp = "";
    LocalUCHARBUFPointer ucbuf(
            ucbuf_open(openFileName.data(), &cp, getShowWarning(), true, &errorCode));
    if(errorCode == U_FILE_ACCESS_ERROR) {
        fprintf(stderr, "couldn't open file %s\n", openFileName.data());
        return;
    }
    if (ucbuf.isNull() || U_FAILURE(errorCode)) {
        fprintf(stderr, "An error occurred processing file %s. Error: %s\n", openFileName.data(), u_errorName(errorCode));
        return;
    }

    /* Parse the data into an SRBRoot */
    LocalPointer<SRBRoot> data(
            parse(ucbuf.getAlias(), inputDir, outputDir, filename.data(), false, false, false, &errorCode));
    if (U_FAILURE(errorCode)) {
        return;
    }

    struct SResource *root = data->fRoot;
    struct SResource *collations = resLookup(root, "collations");
    if (collations != nullptr) {
      struct SResource *collation = resLookup(collations, collationType);

View on GitHub (pinned to 1b2de5e052)

Solutions

  1. Verify the imported file exists at the exact path shown in the error message: `ls -la <path>`
  2. Check file permissions: the file must be readable by the genrb process
  3. Ensure the -s (source/input directory) option matches where the imported files reside
  4. On case-sensitive filesystems (Linux), verify the exact filename casing matches
  5. If the file was recently added, ensure it is included in the build system's file list (e.g. Makefile, BUILD file)
Defensive patterns

Strategy: validation

Validate before calling

# Verify all imported collation files exist before running genrb
INPUT_DIR="./data"
# Find all import references in resource bundles and check their targets
for f in "$INPUT_DIR"/*.txt; do
    while IFS= read -r line; do
        ref=$(echo "$line" | grep -oP 'import\s*"\K[^"]+')
        [ -n "$ref" ] && [ ! -f "$INPUT_DIR/$ref.txt" ] && echo "MISSING: $INPUT_DIR/$ref.txt (referenced in $f)"
    done < "$f"
done

Prevention

When it happens

Trigger: A collation import directive in a resource bundle references a file path that does not exist; the referenced file is in a different directory than expected (inputDir mismatch); the file exists but has restrictive permissions; or the path contains incorrect separators. This occurs in the parse.cpp getRules path, not the main genrb.cpp file-open path.

Common situations: Moving resource bundle files without updating import paths; using relative paths that break when genrb runs from a different working directory; case-sensitivity mismatch on Linux (e.g. 'en_US.txt' vs 'en_US.TXT'); missing collation data files in a custom ICU data build.

Related errors


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