Jguer/yay · error

%w %s

Error message

%w
%s

What it means

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).

Solutions

  1. Verify the config path exists and parses: pacman --config <path> --root <root> -Ss nothing (or run pacmanconf directly with the same flags)
  2. Point --pacmanconf at a valid config (default /etc/pacman.conf)
  3. If using --root, ensure <root>/etc/pacman.conf exists
  4. Validate/fix pacman.conf syntax around the line pacman reports; restore from /etc/pacman.conf.pacnew or the pacman package

Example fix

// before
pacmanConf, stderr, err := pacmanconf.PacmanConf("--config", pacmanConfigPath, "--root", root)
// after
if _, statErr := os.Stat(pacmanConfigPath); statErr != nil {
	return nil, false, fmt.Errorf("pacman config %q not readable: %w", pacmanConfigPath, statErr)
}
pacmanConf, stderr, err := pacmanconf.PacmanConf("--config", pacmanConfigPath, "--root", root)
Defensive patterns

Strategy: try-catch

Validate before calling

if _, err := os.Stat(pacmanConfigPath); err != nil { return fmt.Errorf("pacman config missing: %w", err) }
if root != "/" { if _, err := os.Stat(filepath.Join(root, "etc/pacman.conf")); err != nil { return err } }

Try / catch

conf, _, err := retrievePacmanConfig(...)
if err != nil {
	var perr *fs.PathError
	if errors.As(err, &perr) {
		return fmt.Errorf("pacman.conf unreadable (%s): %w", perr.Path, err)
	}
	return err
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "Config file not found": what it means and how to fix it in docker-sync, Maven, Vagrant, Turborepo and other tools — this error's family across 60 libraries.

Related errors


AI-assisted analysis of Jguer/yay@328f4b4939 (2026-09-07). Data as JSON: /api/errors/10f913da6753f77a. Report an issue: GitHub.

Appendix: source

Thrown at pkg/runtime/pacman.go:23

	"os"

	"github.com/Jguer/yay/v13/pkg/settings/parser"

	pacmanconf "github.com/Morganamilo/go-pacmanconf"
	"golang.org/x/term"
)

func retrievePacmanConfig(cmdArgs *parser.Arguments, pacmanConfigPath string) (*pacmanconf.Config, bool, error) {
	root := "/"
	if value, _, exists := cmdArgs.GetArg("root", "r"); exists {
		root = value
	}

	pacmanConf, stderr, err := pacmanconf.PacmanConf("--config", pacmanConfigPath, "--root", root)
	if err != nil {
		cmdErr := err
		if stderr != "" {
			cmdErr = fmt.Errorf("%w\n%s", err, stderr)
		}

		return nil, false, cmdErr
	}

	if dbPath, _, exists := cmdArgs.GetArg("dbpath", "b"); exists {
		pacmanConf.DBPath = dbPath
	}

	if arch := cmdArgs.GetArgs("arch"); arch != nil {
		pacmanConf.Architecture = append(pacmanConf.Architecture, arch...)
	}

	if ignoreArray := cmdArgs.GetArgs("ignore"); ignoreArray != nil {
		pacmanConf.IgnorePkg = append(pacmanConf.IgnorePkg, ignoreArray...)
	}

	if ignoreGroupsArray := cmdArgs.GetArgs("ignoregroup"); ignoreGroupsArray != nil {

View on GitHub (pinned to 328f4b4939)