{"record":{"id":"384fa6da03efcf9d","repo":"Jguer/yay","slug":"failed-to-retrieve-aur-cache-w","errorCode":null,"errorMessage":"failed to retrieve aur Cache: %w","messagePattern":"failed to retrieve aur Cache: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/cmd/graph/main.go","lineNumber":46,"sourceCode":"\tif errP := cfg.ParseCommandLine(cmdArgs); errP != nil {\n\t\treturn errP\n\t}\n\n\trun, err := runtime.NewRuntime(cfg, cmdArgs, \"1.0.0\")\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tdbExecutor, err := ialpm.NewExecutor(run.PacmanConf, logger)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\taurCache, err := metadata.New(\n\t\tmetadata.WithCacheFilePath(\n\t\t\tfilepath.Join(cfg.BuildDir, \"aur.json\")))\n\tif err != nil {\n\t\treturn fmt.Errorf(\"%s: %w\", gotext.Get(\"failed to retrieve aur Cache\"), err)\n\t}\n\n\tgrapher := dep.NewGrapher(dbExecutor, aurCache, true, settings.NoConfirm,\n\t\tcmdArgs.ExistsDouble(\"d\", \"nodeps\"), false, false,\n\t\trun.Logger.Child(\"grapher\"))\n\n\treturn graphPackage(context.Background(), grapher, cmdArgs.Targets)\n}\n\nfunc main() {\n\tfallbackLog := text.NewLogger(os.Stdout, os.Stderr, os.Stdin, false, \"fallback\")\n\tif err := handleCmd(fallbackLog); err != nil {\n\t\tfallbackLog.Errorln(err)\n\t\tos.Exit(1)\n\t}\n}\n\nfunc graphPackage(","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/Jguer/yay/blob/328f4b4939fb35f38c2f7c7ce3b8638a839bafa5/pkg/cmd/graph/main.go#L28-L64","documentation":"The graph command creates an AUR metadata cache via metadata.New with WithCacheFilePath(<BuildDir>/aur.json). If initializing that cache (reading/creating the cache file) fails, the error is wrapped with gotext.Get('failed to retrieve aur Cache') and returned from handleCmd. metadata.New returns an error when the cache file exists but is unreadable/corrupt or its directory cannot be used.","triggerScenarios":"Running `yay graph` (main → handleCmd) when cfg.BuildDir points to a non-existent or unwritable directory, aur.json exists but is corrupted (bad JSON/truncated), or filesystem permission errors prevent reading/creating the cache file.","commonSituations":"Stale/partial aur.json left by a crash or interrupt; BuildDir moved or cleaned while cache path still configured; running yay as different users (root vs user) causing permission mismatch on the cache file.","solutions":["Delete the corrupt cache file: rm $(yay -Pc 2>/dev/null || echo ~/.cache/yay)/aur.json or the aur.json under the configured BuildDir","Check/fix permissions on BuildDir (chown to the running user)","Recreate BuildDir if missing: mkdir -p <BuildDir>","Reset BuildDir to default (yay config or remove the buildDir option in ~/.config/yay/config.json) and retry"],"exampleFix":"// before\n$ yay graph\nfailed to retrieve aur Cache: open /home/u/.cache/yay/aur.json: syntax error / permission denied\n// after\n$ rm /home/u/.cache/yay/aur.json\n$ yay graph   # cache rebuilt from AUR RPC\n# or programmatically guard:\nif err := os.Remove(filepath.Join(buildDir, \"aur.json\")); err == nil { log.Println(\"stale aur cache removed; retrying\") }","handlingStrategy":"try-catch","validationCode":"cachePath := filepath.Join(cfg.BuildDir, \"aur.json\")\nif fi, err := os.Stat(cachePath); err == nil {\n    if _, e := os.ReadFile(cachePath); e != nil { os.Remove(cachePath) } // unreadable/corrupt → drop\n}\nif err := os.MkdirAll(cfg.BuildDir, 0o755); err != nil { return err }","typeGuard":null,"tryCatchPattern":"aurCache, err := metadata.New(metadata.WithCacheFilePath(cachePath))\nif err != nil {\n    log.Printf(\"aur cache unusable (%v); removing and retrying\", err)\n    _ = os.Remove(cachePath)\n    aurCache, err = metadata.New(metadata.WithCacheFilePath(cachePath))\n    if err != nil { return err }\n}","preventionTips":["Delete aur.json after crashes/interrupts instead of reusing it","Keep BuildDir owned by the single user running yay (never mix root/user runs)","Include aur.json corruption in cache-cleanup routines (yay -Sc equivalent)"],"tags":["aur","cache","metadata"],"backgroundTag":"corrupted-cache-file","analyzedSha":"328f4b4939fb35f38c2f7c7ce3b8638a839bafa5","analyzedAt":"2026-09-07T16:45:12.608Z","contentChangedAt":"2026-09-07T16:45:12.608Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}