JuliusBrussee/caveman · error
open recovery store
Error message
open recovery store %q: %w
What it means
resolveStore opens the durable shared recovery store (ccr) at the resolved path and wraps any ccr.Open failure with the path for diagnosability. It is the single entry point Shrink and Recover use to obtain the store, so any corrupt or unopenable database surfaces here.
Solutions
- Inspect the wrapped cause: `open recovery store ...` followed by the underlying error, and fix accordingly (permissions, disk space)
- Move the corrupt file aside (e.g. `mv ~/.caveman/ccr.db ~/.caveman/ccr.db.bak`) so a fresh store is created
- Check CAVEMAN_CCR_DB points at a valid ccr database, not an arbitrary file
- Ensure you run as the same user that owns the store directory
Example fix
// before export CAVEMAN_CCR_DB=/tmp/leftover.txt // after export CAVEMAN_CCR_DB=$HOME/.caveman/ccr.db
Defensive patterns
Strategy: try-catch
Validate before calling
if dbPath := os.Getenv("CAVEMAN_CCR_DB"); dbPath != "" {
if _, err := os.Stat(dbPath); err != nil && !os.IsNotExist(err) {
// inspect permissions/corruption before calling Shrink
}
} Try / catch
s, closeFn, err := resolveStore(ctx)
if err != nil {
var perr *fs.PathError
if errors.As(err, &perr) { /* handle permission/path issues */ }
return fmt.Errorf("recovery store unavailable: %w", err)
} Prevention
- Run shrink/recover as the same user that owns ~/.caveman
- Back up or move aside ccr.db after version upgrades
- Check disk space and mount writability before long runs
When it happens
Trigger: Calling Shrink or Recover when the recovery store file at CAVEMAN_CCR_DB or $CAVEMAN_HOME/ccr.db (or ~/.caveman/ccr.db) is corrupt, has wrong permissions, is locked, or was created by an incompatible ccr version.
Common situations: Stale ccr.db left over from an upgrade; running under a different user so the 0700 file is unreadable; disk full or read-only filesystem; pointing CAVEMAN_CCR_DB at a non-database file.
Understand the failure class
Background: "open() failed", "failed to open file", "cannot create file" — what a file open error means and how to fix it — this error's family across 42 libraries.
Related errors
- cave_ccr_budget_exceeded
- ccr: recovery storage changed; restart the process and…
- ccr: unknown lifecycle
- check replacement memory
- close open arm
AI-assisted analysis of JuliusBrussee/caveman@3ee70a1026 (2026-09-20).
Data as JSON: /api/errors/6a9530f9a605fb59.
Report an issue: GitHub.
Appendix: source
Thrown at shrink/shrink.go:70
func resolveStore(opts []Option) (*ccr.Store, func() error, error) {
var cfg config
for _, o := range opts {
o(&cfg)
}
if cfg.store != nil {
return cfg.store, func() error { return nil }, nil
}
path := cfg.path
if path == "" {
p, err := defaultCCRPath()
if err != nil {
return nil, nil, err
}
path = p
}
s, err := ccr.Open(path)
if err != nil {
return nil, nil, fmt.Errorf("open recovery store %q: %w", path, err)
}
return s, s.Close, nil
}
// defaultCCRPath resolves the durable shared recovery store path, mirroring the
// engine CLI, MCP server, and proxy: CAVEMAN_CCR_DB, else CAVEMAN_HOME/ccr.db,
// else ~/.caveman/ccr.db. It creates the parent directory so the first shrink on a
// machine succeeds.
func defaultCCRPath() (string, error) {
if p := os.Getenv("CAVEMAN_CCR_DB"); p != "" {
return p, nil
}
home := os.Getenv("CAVEMAN_HOME")
if home == "" {
h, err := os.UserHomeDir()
if err != nil {
return "", fmt.Errorf("resolve home directory: %w", err)
}View on GitHub (pinned to 3ee70a1026)