{"record":{"id":"fabd590215d752b6","repo":"Jguer/yay","slug":"failed-to-open-vcs-file-s-w","errorCode":null,"errorMessage":"failed to open vcs file '%s': %w","messagePattern":"failed to open vcs file '(.+?)': %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/vcs/vcs.go","lineNumber":307,"sourceCode":"\t\tif _, ok := v.OriginsByPackage[pkgName]; ok {\n\t\t\tdelete(v.OriginsByPackage, pkgName)\n\n\t\t\tupdated = true\n\t\t}\n\t}\n\n\tif updated {\n\t\tif err := v.Save(); err != nil {\n\t\t\tfmt.Fprintln(os.Stderr, err)\n\t\t}\n\t}\n}\n\n// LoadStore reads a json file and populates a InfoStore structure.\nfunc (v *InfoStore) Load() error {\n\tvfile, err := os.Open(v.FilePath)\n\tif !os.IsNotExist(err) && err != nil {\n\t\treturn fmt.Errorf(\"failed to open vcs file '%s': %w\", v.FilePath, err)\n\t}\n\n\tdefer vfile.Close()\n\n\tif !os.IsNotExist(err) {\n\t\tdecoder := json.NewDecoder(vfile)\n\t\tif err = decoder.Decode(&v.OriginsByPackage); err != nil {\n\t\t\treturn fmt.Errorf(\"failed to read vcs '%s': %w\", v.FilePath, err)\n\t\t}\n\t}\n\n\treturn nil\n}\n\nfunc (v *InfoStore) CleanOrphans(pkgs map[string]alpm.Package) {\n\tmissing := make([]string, 0)\n\n\tfor pkgName := range v.OriginsByPackage {","sourceCodeStart":289,"sourceCodeEnd":325,"githubUrl":"https://github.com/Jguer/yay/blob/328f4b4939fb35f38c2f7c7ce3b8638a839bafa5/pkg/vcs/vcs.go#L289-L325","documentation":"Returned by `InfoStore.Load` when `os.Open` on the vcs JSON file fails with an error other than NotExist. NotExist is tolerated (empty store), but e.g. permission errors or I/O errors are wrapped with the file path.","triggerScenarios":"Opening `<vcs-file-path>` (the persisted vcs info store) fails with EACCES, EISDIR, or an I/O error; only `os.IsNotExist(err)` bypasses this error.","commonSituations":"Running as a different user than whoever created the vcs file (root vs user cache dirs), the path being a directory, read-only or failing filesystem.","solutions":["Fix permissions/ownership on the vcs file path shown in the message (`ls -l`, `chown`).","If the file is corrupt or unnecessary, delete it — the store is recreated when missing.","Check that the path is a regular file, not a directory."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if info, err := os.Stat(vcsFilePath); err == nil && !info.Mode().IsRegular() {\n    return fmt.Errorf(\"%s is not a regular file\", vcsFilePath)\n}","typeGuard":null,"tryCatchPattern":"store := vcs.NewInfoStore(path)\nif err := store.Load(); err != nil {\n    if errors.Is(err, fs.ErrPermission) {\n        // fix perms or delete the file and continue with an empty store\n    }\n    return err\n}","preventionTips":["Run the tool consistently as the same user so cache files keep one owner","Keep cache directories on a healthy, writable filesystem","Treat the vcs store as disposable cache — safe to delete on trouble"],"tags":["vcs","file-open","permissions","json"],"backgroundTag":"file-open-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"}