{"record":{"id":"10f913da6753f77a","repo":"Jguer/yay","slug":"w-s","errorCode":null,"errorMessage":"%w\n%s","messagePattern":"%w\n%s","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/runtime/pacman.go","lineNumber":23,"sourceCode":"\t\"os\"\n\n\t\"github.com/Jguer/yay/v13/pkg/settings/parser\"\n\n\tpacmanconf \"github.com/Morganamilo/go-pacmanconf\"\n\t\"golang.org/x/term\"\n)\n\nfunc retrievePacmanConfig(cmdArgs *parser.Arguments, pacmanConfigPath string) (*pacmanconf.Config, bool, error) {\n\troot := \"/\"\n\tif value, _, exists := cmdArgs.GetArg(\"root\", \"r\"); exists {\n\t\troot = value\n\t}\n\n\tpacmanConf, stderr, err := pacmanconf.PacmanConf(\"--config\", pacmanConfigPath, \"--root\", root)\n\tif err != nil {\n\t\tcmdErr := err\n\t\tif stderr != \"\" {\n\t\t\tcmdErr = fmt.Errorf(\"%w\\n%s\", err, stderr)\n\t\t}\n\n\t\treturn nil, false, cmdErr\n\t}\n\n\tif dbPath, _, exists := cmdArgs.GetArg(\"dbpath\", \"b\"); exists {\n\t\tpacmanConf.DBPath = dbPath\n\t}\n\n\tif arch := cmdArgs.GetArgs(\"arch\"); arch != nil {\n\t\tpacmanConf.Architecture = append(pacmanConf.Architecture, arch...)\n\t}\n\n\tif ignoreArray := cmdArgs.GetArgs(\"ignore\"); ignoreArray != nil {\n\t\tpacmanConf.IgnorePkg = append(pacmanConf.IgnorePkg, ignoreArray...)\n\t}\n\n\tif ignoreGroupsArray := cmdArgs.GetArgs(\"ignoregroup\"); ignoreGroupsArray != nil {","sourceCodeStart":5,"sourceCodeEnd":41,"githubUrl":"https://github.com/Jguer/yay/blob/328f4b4939fb35f38c2f7c7ce3b8638a839bafa5/pkg/runtime/pacman.go#L5-L41","documentation":"retrievePacmanConfig calls pacmanconf.PacmanConf to parse pacman.conf; on failure it returns the parse/exec error, optionally enriched with pacman's stderr via fmt.Errorf(\"%w\\n%s\", err, stderr). It means the pacman configuration could not be read or parsed, so runtime initialization (db path, repos, mirrors) cannot proceed. The stderr suffix carries pacman's own diagnostic (e.g. file not found, malformed directive).","triggerScenarios":"NewRuntime -> retrievePacmanConfig with --config <pacmanConfigPath> --root <root>; fails when the config file does not exist, is unreadable, or contains invalid pacman.conf syntax, or the pacman executable fails under the given --root.","commonSituations":"User passes a wrong --pacmanconf path; custom root (--root) lacks etc/pacman.conf; hand-edited pacman.conf with a typo; running in a chroot/container without pacman.conf; pacman binary missing from PATH.","solutions":["Verify the config path exists and parses: pacman --config <path> --root <root> -Ss nothing (or run pacmanconf directly with the same flags)","Point --pacmanconf at a valid config (default /etc/pacman.conf)","If using --root, ensure <root>/etc/pacman.conf exists","Validate/fix pacman.conf syntax around the line pacman reports; restore from /etc/pacman.conf.pacnew or the pacman package"],"exampleFix":"// before\npacmanConf, stderr, err := pacmanconf.PacmanConf(\"--config\", pacmanConfigPath, \"--root\", root)\n// after\nif _, statErr := os.Stat(pacmanConfigPath); statErr != nil {\n\treturn nil, false, fmt.Errorf(\"pacman config %q not readable: %w\", pacmanConfigPath, statErr)\n}\npacmanConf, stderr, err := pacmanconf.PacmanConf(\"--config\", pacmanConfigPath, \"--root\", root)","handlingStrategy":"try-catch","validationCode":"if _, err := os.Stat(pacmanConfigPath); err != nil { return fmt.Errorf(\"pacman config missing: %w\", err) }\nif root != \"/\" { if _, err := os.Stat(filepath.Join(root, \"etc/pacman.conf\")); err != nil { return err } }","typeGuard":null,"tryCatchPattern":"conf, _, err := retrievePacmanConfig(...)\nif err != nil {\n\tvar perr *fs.PathError\n\tif errors.As(err, &perr) {\n\t\treturn fmt.Errorf(\"pacman.conf unreadable (%s): %w\", perr.Path, err)\n\t}\n\treturn err\n}","preventionTips":["Stat the config path before invoking pacmanconf","When using --root, confirm <root>/etc/pacman.conf exists first","Lint custom pacman.conf edits (pacman --config <f> -Q) before deploying","Restore stock config from /etc/pacman.conf.pacnew after botched edits"],"tags":["pacman","configuration","error-wrapping"],"backgroundTag":"config-file-not-found","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"}