{"record":{"id":"c85b9315cd5f0046","repo":"nodejs/node","slug":"s-could-not-open-output-file-s-n","errorCode":null,"errorMessage":"%s: could not open output file %s\\n","messagePattern":"(.+?): could not open output file (.+?)\\\\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"deps/icu-small/source/tools/escapesrc/escapesrc.cpp","lineNumber":385,"sourceCode":"int 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;\n  while( getline( inf, linestr)) {\n    no++;\n    if(fixLine(no, linestr)) {\n      goto fail;\n    }\n    outf << linestr << '\\n';\n  }\n\n  if(inf.eof()) {\n    return 0;","sourceCodeStart":367,"sourceCodeEnd":403,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/deps/icu-small/source/tools/escapesrc/escapesrc.cpp#L367-L403","documentation":"After successfully opening the input, convert() opens the output with std::ofstream::open and checks is_open(). Failure means the destination path cannot be written. Unlike the input case, it does NOT call cleanup() here (output may simply be absent), and returns 1.","triggerScenarios":"outf.open(outfile) fails: the parent directory does not exist, the path is a directory, the volume is read-only or full, or the caller lacks write permission.","commonSituations":"Destination directory not created by the build (missing mkdir -p step); output redirected to a path the build user cannot write; disk/quota full in CI; a leftover read-only file at the output path.","solutions":["Ensure the output's parent directory exists and is writable (create it in the build rule with mkdir -p).","Check disk space and quota on the destination volume.","Remove or chmod any stale read-only file occupying the output path."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"import os\noutdir = os.path.dirname(outfile) or '.'\nif not os.path.isdir(outdir) or not os.access(outdir, os.W_OK):\n    raise PermissionError(f'escapesrc output dir not writable: {outdir}')","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Create the output directory in the build rule (mkdir -p) before running escapesrc.","Monitor free disk space in CI to fail fast on ENOSPC."],"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"}