JuliusBrussee/caveman · error · Error
Kilo config root resolves to an empty path
Error message
Kilo config root resolves to an empty path
What it means
When KILO_CONFIG is unset, the CLI derives Kilo's config root from XDG_CONFIG_HOME (or ~/.config), mimicking pinned Kilo behavior of stripping accidental newlines from xdg-basedir output. If, after stripping CR/LF, the root is an empty string, it throws rather than resolving against a meaningless path.
Solutions
- Unset XDG_CONFIG_HOME so the CLI falls back to ~/.config: `unset XDG_CONFIG_HOME`
- Set it to a real absolute directory: `export XDG_CONFIG_HOME="$HOME/.config"`
- Fix the rc/CI file that emits a newline-only value
Example fix
// before export XDG_CONFIG_HOME="" caveman kilo ... // after unset XDG_CONFIG_HOME # or: export XDG_CONFIG_HOME="$HOME/.config"
Defensive patterns
Strategy: validation
Validate before calling
const xdg = process.env.XDG_CONFIG_HOME?.replace(/[\r\n]+/g, "");
if (xdg !== undefined && !xdg) throw new Error("XDG_CONFIG_HOME is empty/newline-only; unset it or set a real path"); Type guard
function isValidXdgRoot(v: string | undefined): boolean {
const cleaned = v?.replace(/[\r\n]+/g, "") ?? "";
return cleaned === "" || isAbsolute(cleaned);
} Try / catch
try {
await kiloCommand();
} catch (e) {
if ((e as Error).message.includes("config root resolves to an empty path")) {
delete process.env.XDG_CONFIG_HOME; // fall back to ~/.config, retry
await kiloCommand();
} else throw e;
} Prevention
- Either unset XDG_CONFIG_HOME or set it to an absolute directory — never empty
- Guard CI/templated exports: skip the export when the template value is blank
- Audit shell rc/direnv files for broken interpolations into XDG variables
When it happens
Trigger: Running a Kilo-related command with XDG_CONFIG_HOME exported as only whitespace/newline characters (e.g. `XDG_CONFIG_HOME=$'\n'`), or an env source that produced an empty-after-cleanup value, while KILO_CONFIG is unset.
Common situations: CI pipelines exporting XDG_CONFIG_HOME from a template variable left empty; shell rc files setting XDG_CONFIG_HOME="" or with accidental line continuations; direnv files with broken interpolation.
Understand the failure class
Background: "is not a valid" / "Invalid ... value" environment variable errors: how libraries validate env vars and what to do when they reject yours — this error's family across 48 libraries.
Related errors
- CAVEMAN_AUTH_TOKEN must be at least
- CAVEMAN_CCR_MAX_BYTES must be a positive integer
- CODEX_HOME points to
- failed to read CODEX_HOME
- secretbox: decrypt
AI-assisted analysis of JuliusBrussee/caveman@3ee70a1026 (2026-09-20).
Data as JSON: /api/errors/e501d44e0ebff0ee.
Report an issue: GitHub.
Appendix: source
Thrown at packages/cli/src/index.ts:11161
// Kilo 7.5.6's native config writer targets KILO_CONFIG_DIR when present. That
// directory is also loaded after KILO_CONFIG, so it must win for effective MCP
// ownership. Explicit KILO_CONFIG wins only without a custom config directory;
// xdg-basedir is the final fallback.
function kiloConfigLocation(): KiloConfigLocation {
const configuredDirectory = process.env.KILO_CONFIG_DIR;
if (configuredDirectory) {
return kiloConfigInDirectory(kiloPathFromEnv(configuredDirectory, "KILO_CONFIG_DIR"), "KILO_CONFIG_DIR");
}
const explicit = process.env.KILO_CONFIG;
if (explicit) {
const path = kiloPathFromEnv(explicit, "KILO_CONFIG");
return { path, jsonc: extname(path).toLowerCase() === ".jsonc", source: "KILO_CONFIG" };
}
// Pinned Kilo strips accidental newlines from xdg-basedir output before use.
const configuredRoot = process.env.XDG_CONFIG_HOME || join(homedir(), ".config");
const cleanedRoot = configuredRoot.replace(/[\r\n]+/g, "");
if (!cleanedRoot) throw new Error("Kilo config root resolves to an empty path");
const root = normalize(isAbsolute(cleanedRoot) ? cleanedRoot : resolve(cleanedRoot));
return kiloConfigInDirectory(join(root, "kilo"), "XDG_CONFIG_HOME");
}
function kiloConfigPath(): string {
return kiloConfigLocation().path;
}
function kiloMcpEntry(mcp: { command: string; args: string[] }): Record<string, unknown> {
return {
type: "local",
command: [mcp.command, ...mcp.args],
enabled: true,
};
}
function kiloMcpEntryMatches(value: unknown, mcp: { command: string; args: string[] }): boolean {
if (!value || typeof value !== "object" || Array.isArray(value)) return false;View on GitHub (pinned to 3ee70a1026)