{"record":{"id":"93416513568fcb95","repo":"Jguer/yay","slug":"reading-architectures-for-srcinfo-w","errorCode":null,"errorMessage":"reading architectures for .SRCINFO: %w","messagePattern":"reading architectures for \\.SRCINFO: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/dep/dep_graph.go","lineNumber":846,"sourceCode":"\t\tif num < 1 || num >= size {\n\t\t\tg.logger.Errorln(gotext.Get(\"invalid value: %d is not between %d and %d\",\n\t\t\t\tnum, 1, size-1))\n\n\t\t\tcontinue\n\t\t}\n\n\t\treturn &options[num-1]\n\t}\n}\n\n// PackagesFromSrcinfo converts repository metadata into package metadata used\n// by dependency resolution and local package information displays.\nfunc PackagesFromSrcinfo(dbExecutor db.Executor, srcInfo *gosrc.Srcinfo) ([]*aur.Pkg, error) {\n\tpkgs := make([]*aur.Pkg, 0, 1)\n\n\talpmArch, err := dbExecutor.AlpmArchitectures()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"reading architectures for .SRCINFO: %w\", err)\n\t}\n\n\talpmArch = append(alpmArch, \"\") // srcinfo assumes no value as \"\"\n\n\tgetDesc := func(pkg *gosrc.Package) string { return cmp.Or(pkg.Pkgdesc, srcInfo.Pkgdesc) }\n\n\t// srcInfo.Packages holds only the per-package overrides; anything declared\n\t// once at the pkgbase level lives on srcInfo itself. Fall back to it so a\n\t// plain (non-split) PKGBUILD does not report these as empty.\n\tfallback := func(pkg, base []string) []string {\n\t\tif len(pkg) > 0 {\n\t\t\treturn pkg\n\t\t}\n\n\t\treturn base\n\t}\n\n\tfor i := range srcInfo.Packages {","sourceCodeStart":828,"sourceCodeEnd":864,"githubUrl":"https://github.com/Jguer/yay/blob/328f4b4939fb35f38c2f7c7ce3b8638a839bafa5/pkg/dep/dep_graph.go#L828-L864","documentation":"PackagesFromSrcinfo converts a parsed .SRCINFO into aur.Pkg entries, and first asks the local database executor for the machine's ALPM architectures via dbExecutor.AlpmArchitectures(). If that query fails, the error is wrapped as 'reading architectures for .SRCINFO: <err>' and returned. This arch list is needed to select the right arch-specific sections of the .SRCINFO (an empty string is appended because srcinfo treats missing arch as no value).","triggerScenarios":"Any call path into PackagesFromSrcinfo (GraphFromSrcinfos, Test* helpers, yay's AUR install when parsing .SRCINFO from a cloned PKGBUILD) where dbExecutor.AlpmArchitectures() fails — typically the pacman/alpm local database can't be opened or read.","commonSituations":"Corrupt or locked pacman local database (/var/lib/pacman/local), mismatched libalpm version, running in a container with a broken pacman db, or permission issues reading the db.","solutions":["Check the pacman db: sudo pacman -Dk (validate) and inspect /var/lib/pacman/local for corruption","Ensure no concurrent pacman/yay holds the db lock; remove stale /var/lib/pacman/db.lck only if no process runs","Re-sync db and verify yay's pacman version matches libalpm: pacman -Sy && yay -V","Recreate the local db from cache if corrupt: sudo pacman -Qqen ... / reinstall flow, or restore from /var/lib/pacman backup"],"exampleFix":"// before\nalpmArch, err := dbExecutor.AlpmArchitectures()\nif err != nil { return nil, fmt.Errorf(\"reading architectures for .SRCINFO: %w\", err) }\n// after\n// diagnose underlying db failure before retrying\nalpmArch, err := dbExecutor.AlpmArchitectures()\nif err != nil {\n    log.Printf(\"alpm db unreadable (%v); running pacman-db validation\", err)\n    if out, e := exec.Command(\"sudo\", \"pacman\", \"-Dk\").CombinedOutput(); e != nil { log.Fatalf(\"pacman db broken: %s\", out) }\n    alpmArch, err = dbExecutor.AlpmArchitectures()\n}","handlingStrategy":"try-catch","validationCode":"// verify pacman local db is readable before parsing srcinfo\nif _, err := os.Stat(\"/var/lib/pacman/local\"); err != nil { return fmt.Errorf(\"pacman local db missing: %w\", err) }\nif err := exec.Command(\"pacman\", \"-Dk\").Run(); err != nil { return fmt.Errorf(\"pacman db invalid: %w\", err) }","typeGuard":null,"tryCatchPattern":"pkgs, err := dep.PackagesFromSrcinfo(dbExecutor, srcInfo)\nif err != nil {\n    if strings.Contains(err.Error(), \"reading architectures for .SRCINFO\") {\n        return fmt.Errorf(\"alpm/pacman database problem; run `pacman -Dk` and check /var/lib/pacman: %w\", err)\n    }\n    return err\n}","preventionTips":["Never delete or hand-edit /var/lib/pacman/local while yay runs","Avoid running pacman/yay concurrently; check db.lck","Keep pacman/yay versions in sync (matching libalpm)","Run pacman -Dk periodically to catch db corruption early"],"tags":["pacman","srcinfo","database"],"backgroundTag":"database-query-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"}