Hmbown/CodeWhale · error
Runtime store path must be a directory
Error message
Runtime store path must be a directory: {} What it means
After rejecting symlinks, reject_symlinked_store_dir also checks metadata.is_dir(); if the store path exists but is a regular file, socket, or other non-directory, opening the store would fail later, so it bails immediately with the path.
Solutions
- Remove the non-directory at that path and let the store create the directory (after backing up any data)
- Correct the store-root config to point at a directory
- Recover data from the file, then `mkdir` the expected directory
Example fix
// before store_root = "/home/u/.codewhale/runtime/store.jsonl" // a file // after mv /home/u/.codewhale/runtime/store.jsonl /home/u/.codewhale/runtime-backup.jsonl store_root = "/home/u/.codewhale/runtime"
Defensive patterns
Strategy: validation
Validate before calling
fn path_is_dir(p: &Path) -> bool {
std::fs::metadata(p).map(|m| m.is_dir()).unwrap_or(false)
} Type guard
fn existing_dir(p: &Path) -> Option<()> {
std::fs::metadata(p).ok()?.is_dir().then_some(())
} Try / catch
if !path_is_dir(&store_root) {
eprintln!("store root {} is not a directory; fix config", store_root.display());
std::process::exit(2);
} Prevention
- Verify the store-root config value points at a directory, not a file
- Distinguish file-store vs dir-store config keys clearly
- Back up and remove stray files before the store creates its directory
When it happens
Trigger: The configured store path exists but is not a directory — commonly a regular file created by a misconfigured path (e.g. store root pointing at a file, or a file created where a dir was expected).
Common situations: Store root set to the path of a file (wrong config key); a previous single-file store layout; `touch`ed placeholder files; path collisions after migration.
Related errors
- Automation lock must be a regular file
- budget baseline_receipt path changed
- cloud job id must look like cloud_
- Codewhale credentials directory cannot be a volume root
- Codewhale credentials directory has an unsupported component
AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22).
Data as JSON: /api/errors/e6e624581e52d6a5.
Report an issue: GitHub.
Appendix: source
Thrown at crates/tui/src/runtime_threads.rs:13919
.set_len(original_len)
.context("Failed to roll back Runtime event")?;
rollback_file
.sync_all()
.context("Failed to sync Runtime event rollback")
}
fn reject_symlinked_store_dir(path: &Path) -> Result<()> {
let Ok(metadata) = fs::symlink_metadata(path) else {
return Ok(());
};
if metadata.file_type().is_symlink() {
bail!(
"Runtime store directory must not be a symlink: {}",
path.display()
);
}
if !metadata.is_dir() {
bail!("Runtime store path must be a directory: {}", path.display());
}
Ok(())
}
fn ensure_runtime_store_dir(path: &Path) -> Result<()> {
fs::create_dir_all(path).with_context(|| format!("Failed to create {}", path.display()))?;
reject_symlinked_store_dir(path)
}
fn read_complete_event(
reader: &mut impl BufRead,
path: &Path,
) -> Result<Option<RuntimeEventRecord>> {
Ok(read_complete_event_bytes(reader, path)?.map(|(event, _)| event))
}
fn read_complete_event_bytes(
reader: &mut impl BufRead,View on GitHub (pinned to 73e0f67d83)