{"record":{"id":"6c2b4aad0631e12e","repo":"Jguer/yay","slug":"failed-to-retrieve-aur-cache-w-6c2b4a","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/runtime/runtime.go","lineNumber":97,"sourceCode":"\tvoteClient.SetCredentials(\n\t\tos.Getenv(\"AUR_USERNAME\"),\n\t\tos.Getenv(\"AUR_PASSWORD\"))\n\n\tuserAgentFn := func(ctx context.Context, req *http.Request) error {\n\t\treq.Header.Set(\"User-Agent\", userAgent)\n\t\treturn nil\n\t}\n\n\tvar aurCache aur.QueryClient\n\taurCache, errAURCache := metadata.New(\n\t\tmetadata.WithHTTPClient(httpClient),\n\t\tmetadata.WithCacheFilePath(filepath.Join(cfg.BuildDir, \"aur.json\")),\n\t\tmetadata.WithRequestEditorFn(userAgentFn),\n\t\tmetadata.WithBaseURL(cfg.AURURL),\n\t\tmetadata.WithDebugLogger(logger.Debugln),\n\t)\n\tif errAURCache != nil {\n\t\treturn nil, fmt.Errorf(gotext.Get(\"failed to retrieve aur Cache\")+\": %w\", errAURCache)\n\t}\n\n\taurClient, errAUR := rpc.NewClient(\n\t\trpc.WithHTTPClient(httpClient),\n\t\trpc.WithBaseURL(cfg.AURRPCURL),\n\t\trpc.WithRequestEditorFn(userAgentFn),\n\t\trpc.WithLogFn(logger.Debugln))\n\tif errAUR != nil {\n\t\treturn nil, errAUR\n\t}\n\n\tif cfg.UseRPC {\n\t\taurCache = aurClient\n\t}\n\n\tpacmanConf, useColor, err := retrievePacmanConfig(cmdArgs, cfg.PacmanConf)\n\tif err != nil {\n\t\treturn nil, err","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/Jguer/yay/blob/328f4b4939fb35f38c2f7c7ce3b8638a839bafa5/pkg/runtime/runtime.go#L79-L115","documentation":"NewRuntime wraps any failure from building the AUR metadata cache (metadata.NewCache with a cache file path, request editor and base URL) into 'failed to retrieve aur Cache: <cause>'. The library throws it because without the on-disk AUR cache (aur.json in the build dir) it cannot serve package metadata. It is a wrap of the underlying cause, so the real problem (network, bad URL, unwritable cache path) is in the %w chain.","triggerScenarios":"Calling NewRuntime (directly from main/handleCmd or in tests like TestBuildRuntime) when metadata.NewCache fails: the AUR base URL is unreachable/misconfigured (cfg.AURURL), the cache file aur.json cannot be created/read under cfg.BuildDir, or the HTTP client setup fails.","commonSituations":"First run with no network or a proxy blocking aur.archlinux.org; a custom AURURL pointing at a mirror that is down or misspelled; a read-only or non-existent BuildDir so aur.json cannot be written; corrupted/stale aur.json causing a read error.","solutions":["Check the wrapped cause with errors.Unwrap/ %+v to see whether it is a network error, bad URL, or file error","Verify cfg.AURURL is a valid AUR metadata base URL and reachable (curl it)","Ensure cfg.BuildDir exists and is writable so aur.json can be created","Delete a possibly corrupt aur.json in the build dir and retry","Fix network/proxy/VPN connectivity, then rerun"],"exampleFix":"// before\nrt, err := runtime.NewRuntime(cfg)\nif err != nil { log.Fatal(err) }\n// after\nrt, err := runtime.NewRuntime(cfg)\nif err != nil {\n\tlog.Fatalf(\"runtime init failed (check AURURL/BuildDir/network): %v\", err)\n}","handlingStrategy":"try-catch","validationCode":"if _, err := os.Stat(filepath.Join(cfg.BuildDir, \"aur.json\")); err != nil { os.MkdirAll(cfg.BuildDir, 0o755) }\nif resp, err := http.Get(cfg.AURURL); err != nil || resp.StatusCode != 200 { /* fix AURURL/network before NewRuntime */ }","typeGuard":"func aurCacheReachable(cfg *Config) bool {\n\tif cfg == nil || cfg.AURURL == \"\" { return false }\n\tresp, err := http.Head(cfg.AURURL)\n\treturn err == nil && resp.StatusCode == 200\n}","tryCatchPattern":"rt, err := runtime.NewRuntime(cfg)\nvar aurCacheErr *fmt.WrapError\nif errors.As(err, &aurCacheErr) && strings.Contains(err.Error(), \"failed to retrieve aur Cache\") {\n\t// fall back to RPC-only or offline mode\n}","preventionTips":["Pre-create and writable-check cfg.BuildDir before starting","Validate AURURL with a HEAD request at startup","Handle offline mode explicitly instead of failing hard","Periodically refresh/delete stale aur.json"],"tags":["network","cache","aur","configuration"],"backgroundTag":"http-request-failed","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"}