{"record":{"id":"bfff57b33a4ddd8f","repo":"JuliusBrussee/caveman","slug":"kilo-data-root-resolves-to-an-empty-path","errorCode":null,"errorMessage":"Kilo data root resolves to an empty path","messagePattern":"Kilo data root resolves to an empty path","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/cli/src/index.ts","lineNumber":11660,"sourceCode":"  // but managed loading deliberately excludes it.\n  const configFiles = [\"kilo.jsonc\", \"kilo.json\", \"opencode.jsonc\", \"opencode.json\"];\n  if (configFiles.some((name) => existsSync(join(directory, name)))) return true;\n  if (process.platform !== \"darwin\") return false;\n  const preferenceFiles = [\"/Library/Managed Preferences/ai.opencode.managed.plist\"];\n  try {\n    preferenceFiles.unshift(join(\"/Library/Managed Preferences\", userInfo().username, \"ai.opencode.managed.plist\"));\n  } catch {\n    // System-level preference remains covered; an unreadable username is itself\n    // unusual, but no user path can be resolved safely enough to claim absence.\n    return true;\n  }\n  return preferenceFiles.some((path) => existsSync(path));\n}\n\nfunction kiloDatabasePath(): string | null {\n  const rawDataRoot = process.env.XDG_DATA_HOME || join(homedir(), \".local\", \"share\");\n  const cleanedDataRoot = rawDataRoot.replace(/[\\r\\n]+/g, \"\");\n  if (!cleanedDataRoot) throw new Error(\"Kilo data root resolves to an empty path\");\n  const dataRoot = normalize(isAbsolute(cleanedDataRoot) ? cleanedDataRoot : resolve(cleanedDataRoot));\n  const configured = process.env.KILO_DB;\n  if (configured === \":memory:\") return null;\n  if (configured) {\n    if (/[\\0\\r\\n]/.test(configured)) throw new Error(\"KILO_DB contains an invalid path character\");\n    return normalize(isAbsolute(configured) ? configured : join(dataRoot, \"kilo\", configured));\n  }\n  return join(dataRoot, \"kilo\", \"kilo.db\");\n}\n\nfunction kiloActiveOrganizationState(): \"none\" | \"active\" | \"unknown\" {\n  let path: string | null;\n  try {\n    path = kiloDatabasePath();\n    if (path === null) return \"none\";\n    const stat = statSync(path);\n    if (!stat.isFile()) return \"unknown\";\n  } catch (error) {","sourceCodeStart":11642,"sourceCodeEnd":11678,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/5184b3d11ac6a1acb7d44b9bfaa31698157cff97/packages/cli/src/index.ts#L11642-L11678","documentation":"Sanity check when resolving Kilo's data root: the computed directory path is empty, analogous to the config-root guard. Environment variables steering Kilo's data location are set to values that resolve to an empty string, so subsequent path joins would be meaningless.","triggerScenarios":"Thrown at packages/cli/src/index.ts:11660 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Set the Kilo data-root environment variable to a non-empty absolute path","Unset the variable so the default data location is used","Fix shell scripts that export it with an unset or blank value"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"5184b3d11ac6a1acb7d44b9bfaa31698157cff97","analyzedAt":"2026-09-06T12:00:26.372Z","contentChangedAt":"2026-09-06T12:00:26.372Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}