{"record":{"id":"27fe0aedb73303d8","repo":"mozilla/pdf.js","slug":"cmap-files-were-not-found","errorCode":null,"errorMessage":"cmap files were not found","messagePattern":"cmap files were not found","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"gulpfile.mjs","lineNumber":1301,"sourceCode":"      .src(`${L10N_DIR}/${glob}/viewer.ftl`, {\n        base: L10N_DIR,\n        encoding: false,\n      })\n      .pipe(gulp.dest(VIEWER_LOCALE_OUTPUT)),\n  ]);\n});\n\ngulp.task(\"cmaps\", async function () {\n  const CMAP_INPUT = \"external/cmaps\";\n  const VIEWER_CMAP_OUTPUT = \"external/bcmaps\";\n\n  console.log(\"\\n### Building cmaps\");\n\n  // Testing a file that usually present.\n  if (!checkFile(CMAP_INPUT + \"/UniJIS-UCS2-H\")) {\n    console.log(\"./external/cmaps has no cmap files, download them from:\");\n    console.log(\"  https://github.com/adobe-type-tools/cmap-resources\");\n    throw new Error(\"cmap files were not found\");\n  }\n\n  // Remove old bcmap files.\n  fs.readdirSync(VIEWER_CMAP_OUTPUT).forEach(function (file) {\n    if (/\\.bcmap$/i.test(file)) {\n      fs.unlinkSync(VIEWER_CMAP_OUTPUT + \"/\" + file);\n    }\n  });\n\n  const { compressCmaps } =\n    await import(\"./external/cmapscompress/compress.mjs\");\n  compressCmaps(CMAP_INPUT, VIEWER_CMAP_OUTPUT, true);\n});\n\nfunction preprocessCSS(source, defines) {\n  const outName = getTempFile(\"~preprocess\", \".css\");\n  preprocess(source, outName, defines);\n  const out = fs.readFileSync(outName).toString();","sourceCodeStart":1283,"sourceCodeEnd":1319,"githubUrl":"https://github.com/mozilla/pdf.js/blob/5903d58d58e4dd9ce6ffa3834aea8480f06b4ada/gulpfile.mjs#L1283-L1319","documentation":"The `cmaps` gulp task compresses Adobe text CMaps from `external/cmaps` into binary `.bcmap` files under `external/bcmaps`. As a sanity check it tests for a known sentinel file (`external/cmaps/UniJIS-UCS2-H`); if that file is absent, the directory does not contain the Adobe CMap resources, so the task aborts rather than producing an empty/partial bcmap set. The error message points the user at the upstream source.","triggerScenarios":"Fresh clone where `external/cmaps` was never populated; the cmap-resources archive was downloaded but extracted to the wrong path; a git operation removed the files; the directory exists but `UniJIS-UCS2-H` specifically is missing (incomplete download).","commonSituations":"First-time build of a distro package that needs CJK font support; CI that doesn't pre-fetch cmap resources; a contributor following old docs that omit the download step.","solutions":["Download Adobe CMap resources from https://github.com/adobe-type-tools/cmap-resources and place the text CMaps into `external/cmaps/` (ensure `UniJIS-UCS2-H` is present).","Verify with `ls external/cmaps/UniJIS-UCS2-H` before running `gulp cmaps`.","If you don't need CJK font support in your build, skip the `cmaps` task entirely.","Re-extract a truncated archive (the sentinel file missing usually means the whole set is incomplete)."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"import { existsSync } from 'fs';\nfunction preflightCmaps() {\n  if (!existsSync('external/cmaps/UniJIS-UCS2-H')) {\n    throw new Error('external/cmaps missing; download from https://github.com/adobe-type-tools/cmap-resources');\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Document the cmap-resources download as a prerequisite for `gulp cmaps`.","If you don't need CJK font support, skip the cmaps task rather than running it against an empty dir.","Verify the sentinel file exists in CI before invoking the build."],"tags":["build","cmaps","setup","external-resources","fonts"],"backgroundTag":null,"analyzedSha":"5903d58d58e4dd9ce6ffa3834aea8480f06b4ada","analyzedAt":"2026-08-13T02:28:27.364Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}