Skip to main content

default_cache_root

Function default_cache_root 

pub fn default_cache_root() -> PathBuf
Expand description

Return dirs::cache_dir() or fall back to a user-namespaced subdir of /tmp when the XDG dirs are unavailable (headless CI, containers, etc.).

The fallback used to be a bare /tmp — which, combined with the per-repo codelore/<repo_hash_8>/<key>.duckdb join later, produced /tmp/codelore/... under whichever user first invoked codelore on a shared host. Subsequent users hit EPERM because the directory was owned by user A and lacked group-write. The fallback now namespaces by $USER / $LOGNAME / $USERNAME, falling back to a process-id suffix if none are set (the latter case is essentially containers/sandboxes where the OS already provides isolation, so PID only needs to avoid same-process collisions).