{"record":{"id":"2a2a81cff5e28342","repo":"benbjohnson/litestream","slug":"dry-run-failed-w","errorCode":null,"errorMessage":"dry run failed: %w","messagePattern":"dry run failed: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/litestream/reset.go","lineNumber":96,"sourceCode":"\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"cannot create database from config: %w\", err)\n\t\t}\n\t} else {\n\t\tdb = litestream.NewDB(dbPath)\n\t}\n\n\t// Check if meta path exists\n\tmetaPath := db.MetaPath()\n\tif _, err := os.Stat(metaPath); os.IsNotExist(err) {\n\t\tfmt.Printf(\"No local state to reset for %s\\n\", dbPath)\n\t\tfmt.Printf(\"Meta directory does not exist: %s\\n\", metaPath)\n\t\treturn nil\n\t}\n\n\tif *dryRun {\n\t\tfiles, err := localLTXFiles(db.LTXDir())\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"dry run failed: %w\", err)\n\t\t}\n\n\t\tfmt.Printf(\"Dry run: local Litestream state would be reset for: %s\\n\", dbPath)\n\t\tfmt.Printf(\"Would remove: %s\\n\", db.LTXDir())\n\t\tif len(files) == 0 {\n\t\t\tfmt.Println(\"No local LTX files would be removed.\")\n\t\t\treturn nil\n\t\t}\n\n\t\tfmt.Println(\"Files that would be removed:\")\n\t\tfor _, file := range files {\n\t\t\tfmt.Printf(\"  %s\\n\", file)\n\t\t}\n\t\tfmt.Println(\"No files were removed.\")\n\t\treturn nil\n\t}\n\n\t// Perform the reset","sourceCodeStart":78,"sourceCodeEnd":114,"githubUrl":"https://github.com/benbjohnson/litestream/blob/4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3/cmd/litestream/reset.go#L78-L114","documentation":"`litestream reset --dry-run` enumerates the local LTX files under the database's LTX directory (db.LTXDir()) so it can print what a real reset would remove. If listing those files fails — unreadable directory, permission problems, filesystem errors — the failure is wrapped as \"dry run failed\" and the command exits before printing the plan. No files are modified because dry-run only reads.","triggerScenarios":"`litestream reset <dbpath> --dry-run` where localLTXFiles(db.LTXDir()) cannot read the LTX directory: directory deleted or renamed mid-run, wrong permissions, path is not a directory, or an I/O error reading directory entries.","commonSituations":"Running reset as a non-root user against a root-owned db directory; the database path typo'd so the LTX dir resolves to a file; NFS/network volumes returning I/O errors; state already partially removed by a previous reset.","solutions":["Check the wrapped inner error to see whether it is a permission or not-found problem","Verify the db path and that `<dbdir>/.-litestream` (LTX dir) exists and is readable: `ls -la <dbpath>/.litestream`","Re-run with sufficient permissions (sudo or correct user/group ownership)","If the directory is already gone, the reset target state may already be achieved — run without --dry-run or skip the reset"],"exampleFix":"// before\nsudo -u app litestream reset /var/lib/db/app.db --dry-run\n// permission denied on /var/lib/db/app.db/.litestream\n// after\nsudo litestream reset /var/lib/db/app.db --dry-run","handlingStrategy":"validation","validationCode":"ltxDir := filepath.Join(filepath.Dir(dbPath), \".litestream\")\nfi, err := os.Stat(ltxDir)\nif err != nil { return fmt.Errorf(\"ltx dir missing: %w\", err) }\nif !fi.IsDir() { return fmt.Errorf(\"%s is not a directory\", ltxDir) }\nif err := unix.Access(ltxDir, unix.R_OK); err != nil {\n    return fmt.Errorf(\"ltx dir not readable: %w\", err)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run reset under the same user that owns the database files","Check the LTX dir exists and is readable before dry-run in scripts","Avoid NFS/network volumes for litestream state when possible"],"tags":["cli","filesystem","dry-run"],"backgroundTag":"file-read-failed","analyzedSha":"4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3","analyzedAt":"2026-09-06T18:29:25.564Z","contentChangedAt":"2026-09-06T18:29:25.564Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}