{"record":{"id":"e7ec3cf12d707edb","repo":"nodejs/node","slug":"s-could-not-open-input-file-s-n","errorCode":null,"errorMessage":"%s: could not open input file %s\\n","messagePattern":"(.+?): could not open input file (.+?)\\\\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"deps/icu-small/source/tools/escapesrc/escapesrc.cpp","lineNumber":375,"sourceCode":"  //fprintf(stderr, \"%d - fixed\\n\", no);\n  return false;\n}\n\n/**\n * Convert a whole file\n * @param infile\n * @param outfile\n * @return 1 on err, 0 otherwise\n */\nint convert(const std::string &infile, const std::string &outfile) {\n  fprintf(stderr, \"escapesrc: %s -> %s\\n\", infile.c_str(), outfile.c_str());\n\n  std::ifstream inf;\n  \n  inf.open(infile.c_str(), std::ios::in);\n\n  if(!inf.is_open()) {\n    fprintf(stderr, \"%s: could not open input file %s\\n\", prog.c_str(), infile.c_str());\n    cleanup(outfile);\n    return 1;\n  }\n\n  std::ofstream outf;\n\n  outf.open(outfile.c_str(), std::ios::out);\n\n  if(!outf.is_open()) {\n    fprintf(stderr, \"%s: could not open output file %s\\n\", prog.c_str(), outfile.c_str());\n    return 1;\n  }\n\n  // TODO: any platform variations of #line?\n  outf << \"#line 1 \\\"\" << infile << \"\\\"\" << '\\n';\n\n  int no = 0;\n  std::string linestr;","sourceCodeStart":357,"sourceCodeEnd":393,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/deps/icu-small/source/tools/escapesrc/escapesrc.cpp#L357-L393","documentation":"convert() opens the input file with std::ifstream::open and checks is_open(). If opening fails (missing path, no read permission, or directory), it prints this message, calls cleanup() to delete any stale output, and returns 1. This guards against silently producing output from a nonexistent input.","triggerScenarios":"inf.open(infile) fails: the path does not exist, points to a directory rather than a file, lacks read permission, or contains a typo. is_open() returns false in all these cases.","commonSituations":"Wrong relative path because the tool's working directory differs from the build rule's expectation; a generated input that an earlier build step failed to produce; permission/ownership mismatch in a CI container; a make/ninja dependency edge missing so the input is not yet built.","solutions":["Verify the input path exists and is readable: check the path printed in the message, resolve it relative to escapesrc's cwd.","Fix the build dependency so the input file is generated before escapesrc runs.","Correct file permissions or ownership if access is denied."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"import os\nif not os.path.isfile(infile) or not os.access(infile, os.R_OK):\n    raise FileNotFoundError(f'escapesrc input not readable: {infile}')","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Declare the input as a build dependency so the build system guarantees it exists.","Log escapesrc's working directory in build rules to catch relative-path mistakes."],"tags":["icu","escapesrc","file-io","filesystem"],"backgroundTag":null,"analyzedSha":"1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e","analyzedAt":"2026-08-13T00:53:24.642Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}