{"record":{"id":"fa52dd597c24a33e","repo":"docmirror/dev-sidecar","slug":"error-fa52dd","errorCode":null,"errorMessage":"证书路径为空，无法安装根证书。请确认证书文件已生成。","messagePattern":"证书路径为空，无法安装根证书。请确认证书文件已生成。","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/core/src/shell/scripts/setup-ca.js","lineNumber":9,"sourceCode":"const fs = require('node:fs')\nconst Shell = require('../shell')\n\nconst execute = Shell.execute\n\nconst executor = {\n  async windows (exec, { certPath }) {\n    if (!certPath) {\n      throw new Error('证书路径为空，无法安装根证书。请确认证书文件已生成。')\n    }\n    if (!fs.existsSync(certPath)) {\n      throw new Error(`证书文件不存在: ${certPath}`)\n    }\n    const cmds = [`start \"\" \"${certPath}\"`]\n    await exec(cmds, { type: 'cmd' })\n    return true\n  },\n  async linux (exec, { certPath }) {\n    if (!certPath) {\n      throw new Error('证书路径为空，无法安装根证书。请确认证书文件已生成。')\n    }\n    if (!fs.existsSync(certPath)) {\n      throw new Error(`证书文件不存在: ${certPath}`)\n    }\n    const cmds = [`sudo cp ${certPath} /usr/local/share/ca-certificates`, 'sudo update-ca-certificates ']\n    await exec(cmds)\n    return true","sourceCodeStart":1,"sourceCodeEnd":27,"githubUrl":"https://github.com/docmirror/dev-sidecar/blob/7710cd56cce760c708f30b01d2d4056eb8c402d5/packages/core/src/shell/scripts/setup-ca.js#L1-L27","documentation":"During Windows root-CA installation, the setup-ca executor expects the path of the generated dev-sidecar CA certificate. When setupCa() is invoked with certPath undefined/empty, it throws this error instead of running `start <certPath>`. It signals that the CA certificate generation step never produced a path, so installation cannot proceed.","triggerScenarios":"Calling setupCa(exec, { certPath: undefined }) / ({ certPath: '' }) on Windows; the caller (typically the core cert module) failed to resolve the CA path (e.g. cert generation was skipped, or the cert config was overridden to empty) before invoking the executor.","commonSituations":"First-run CA generation failed or was interrupted so no cert file was created; user config pointed `cert.certPath` to an empty value; calling the shell setup script directly without passing certPath; ~/.dev-sidecar directory not writable so cert generation silently failed.","solutions":["Ensure the CA certificate is generated first (restart the app so the core cert module regenerates ~/.dev-sidecar/dev-sidecar.ca.crt)","Check user config (~/.dev-sidecar/config.json) for an empty/overridden cert path and remove it so the default path is used","Verify ~/.dev-sidecar is writable by the current user","If calling the API directly, pass a valid certPath: setupCa(exec, { certPath: '~/.dev-sidecar/dev-sidecar.ca.crt' })"],"exampleFix":"// before\nawait shell.setupCa(exec, { certPath: config.cert && config.cert.path }) // undefined when cert config missing\n// after\nconst certPath = (config.cert && config.cert.path) || getDefaultCaCertPath()\nif (!fs.existsSync(certPath)) await certApi.generateRootCert()\nawait shell.setupCa(exec, { certPath })","handlingStrategy":"validation","validationCode":"const fs = require('fs')\nconst path = require('path')\nconst certPath = path.join(os.homedir(), '.dev-sidecar', 'dev-sidecar.ca.crt')\nif (!certPath) throw new Error('certPath must be resolved before setupCa')","typeGuard":"function hasCertPath(opts) { return opts != null && typeof opts.certPath === 'string' && opts.certPath.trim() !== '' }","tryCatchPattern":"try {\n  await shell.setupCa(exec, { certPath })\n} catch (e) {\n  if (String(e.message).includes('证书路径为空')) {\n    log.error('CA cert not generated yet; regenerate before install')\n    await certApi.generateRootCert()\n    await shell.setupCa(exec, { certPath })\n  } else { throw e }\n}","preventionTips":["Always generate the root CA before calling setupCa","Never override the cert path with an empty value in ~/.dev-sidecar/config.json","Verify ~/.dev-sidecar is writable on first run","Log the resolved certPath before installation for easier diagnosis"],"tags":["certificate","windows","missing-argument"],"backgroundTag":"ca-cert-path-missing","analyzedSha":"7710cd56cce760c708f30b01d2d4056eb8c402d5","analyzedAt":"2026-08-31T22:07:07.234Z","schemaVersion":2},"datasetVersion":"2026-08-31T22:30:34.772Z"}