nodejs/node · error

couldn't open file %s

Error message

couldn't open file %s

What it means

Inside processFile(), after constructing openFileName (from inputDir + the resource filename), genrb calls ucbuf_open() to read and decode the source .txt. If the returned status is exactly U_FILE_ACCESS_ERROR, it prints "couldn't open file <path>" and returns from processFile without aborting the whole run, so other files in the batch continue. This is the input-file equivalent of error 767.

Source

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

             */
            if( (filename[0] != U_FILE_SEP_CHAR) && (inputDir[dirlen-1] !='.')){
                openFileName.append(inputDir, status);
            }
        } else {
            openFileName.append(inputDir, status);
        }
    }
    openFileName.appendPathPart(filename, status);

    // Test for CharString failure
    if (U_FAILURE(status)) {
        return;
    }

    ucbuf.adoptInstead(ucbuf_open(openFileName.data(), &cp,getShowWarning(),true, &status));
    if(status == U_FILE_ACCESS_ERROR) {

        fprintf(stderr, "couldn't open file %s\n", openFileName.data());
        return;
    }
    if (ucbuf.isNull() || U_FAILURE(status)) {
        fprintf(stderr, "An error occurred processing file %s. Error: %s\n",
                openFileName.data(), u_errorName(status));
        return;
    }
    /* auto detected popular encodings? */
    if (cp!=nullptr && isVerbose()) {
        printf("autodetected encoding %s\n", cp);
    }
    /* Parse the data into an SRBRoot */
    data.adoptInstead(parse(ucbuf.getAlias(), inputDir, outputDir, filename,
            !omitBinaryCollation, options[NO_COLLATION_RULES].doesOccur, options[ICU4X_MODE].doesOccur, &status));

    if (data.isNull() || U_FAILURE(status)) {
        fprintf(stderr, "couldn't parse the file %s. Error:%s\n", filename, u_errorName(status));
        return;

View on GitHub (pinned to 1b2de5e052)

Solutions

  1. Verify the printed path exists: `ls -l <openFileName>`.
  2. Check --sourcedir / the current working directory and the filename spelling/case.
  3. Ensure the source .txt is readable by the user running genrb.

Example fix

// before
genrb -s wrong/dir root.txt
// after
genrb -s correct/dir root.txt
Defensive patterns

Strategy: validation

Validate before calling

src_dir="${SOURCEDIR:-.}"
for f in "$@"; do
  if [ ! -r "$src_dir/$f" ]; then
    echo "ERROR: source file '$src_dir/$f' missing or unreadable" >&2; exit 2
  fi
done

Try / catch

genrb -s "$src_dir" "$@" 2>err.log
if grep -q "couldn't open file" err.log; then
  echo "One or more source .txt files were not found in $src_dir" >&2; exit 1
fi

Prevention

When it happens

Trigger: Passing a filename that does not exist under the source directory; wrong --sourcedir; typos in the file list; permission denied on a source .txt.

Common situations: Build scripts globbing a list that includes stale entries; running genrb from the wrong working directory; case-sensitivity mismatches between macOS/Windows and Linux checkouts.

Related errors


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