{"record":{"id":"2330fd2af2ab6a50","repo":"itwanger/toBeBetterJavaer","slug":"sidebar-file-not-found-options-sidebar","errorCode":null,"errorMessage":"Sidebar file not found: ${options.sidebar}","messagePattern":"Sidebar file not found: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/sync-sidebar.js","lineNumber":132,"sourceCode":"        route: options.route,\n        dir: options.dir,\n        fallbackGroup: options.fallbackGroup,\n      },\n    ];\n  }\n  return DEFAULT_TARGETS;\n}\n\nfunction main() {\n  try {\n    const options = parseArgs(process.argv.slice(2));\n    if (options.help) {\n      printHelp();\n      return;\n    }\n\n    if (!fs.existsSync(options.sidebar)) {\n      throw new Error(`Sidebar file not found: ${options.sidebar}`);\n    }\n\n    let source = fs.readFileSync(options.sidebar, \"utf8\");\n    const originalSource = source;\n    const reports = [];\n\n    for (const target of createTargets(options)) {\n      const result = syncTarget(source, target);\n      source = result.source;\n      reports.push(result.report);\n    }\n\n    const changed = source !== originalSource;\n    for (const report of reports) {\n      if (options.verbose || report.added.length > 0 || report.removed.length > 0 || report.warnings.length > 0) {\n        printReport(report);\n      }\n    }","sourceCodeStart":114,"sourceCodeEnd":150,"githubUrl":"https://github.com/itwanger/toBeBetterJavaer/blob/6617f5fd0b0597735bdc028f2fcd036817877327/scripts/sync-sidebar.js#L114-L150","documentation":"Thrown by main() in scripts/sync-sidebar.js when the sidebar file (default <repo>/docs/src/.vuepress/sidebar.ts, overridable with --sidebar, resolved against the repo root) does not exist. The check runs before any parsing, so nothing is read or modified.","triggerScenarios":"`--sidebar` pointing at a moved/renamed file; running from a fork where sidebar.ts has a different layout; typo in the path; running outside the repo with a cwd-relative path that resolves wrongly against ROOT_DIR.","commonSituations":"VuePress config restructured (e.g. sidebar moved out of .vuepress or renamed to .ts->.js); path given relative to the wrong base; case-sensitivity differences on Linux.","solutions":["Confirm the file exists: `ls docs/src/.vuepress/sidebar.ts` from the repo root","Pass the correct path with `--sidebar=<path>` (resolved relative to the repo root, so repo-relative paths work)","If the sidebar truly moved, update the DEFAULT_SIDEBAR constant or always pass --sidebar"],"exampleFix":"# before\nnode scripts/sync-sidebar.js --sidebar=docs/.vuepress/sidebar.ts\n\n# after\nnode scripts/sync-sidebar.js --sidebar=docs/src/.vuepress/sidebar.ts","handlingStrategy":"validation","validationCode":"const sidebar = path.resolve(REPO_ROOT, sidebarArg || \"docs/src/.vuepress/sidebar.ts\");\nif (!fs.existsSync(sidebar)) { console.error(`sidebar.ts missing at ${sidebar} — pass --sidebar=<path>`); process.exit(2); }","typeGuard":"const sidebarExists = (p) => fs.existsSync(path.resolve(REPO_ROOT, p || \"docs/src/.vuepress/sidebar.ts\"));","tryCatchPattern":"catch (err) { if (err.message.startsWith(\"Sidebar file not found:\")) { console.error(\"Point --sidebar at the real file (paths resolve from the repo root)\"); process.exit(2); } throw err; }","preventionTips":["If your fork moves sidebar.ts, always pass --sidebar or update DEFAULT_SIDEBAR","Check with ls before first run on a new checkout","Path resolves against the repo root, not cwd"],"tags":["filesystem","configuration","cli"],"backgroundTag":null,"analyzedSha":"6617f5fd0b0597735bdc028f2fcd036817877327","analyzedAt":"2026-08-14T14:50:55.107Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}