Jguer/yay · error

: read PKGBUILD

Error message

%s %s: read PKGBUILD: %w

What it means

Wraps `os.ReadFile` failures when reading a PKGBUILD from an AUR package's clone/build directory while emitting an AUR pre-install (or post-download) event. Without the PKGBUILD the Lua event cannot be populated, so the operation aborts with the event name and pkgbase in the message.

Solutions

  1. Re-clone the package build dir: remove `<cachedir>/<base>` and rerun the install so git re-downloads the PKGBUILD.
  2. Check permissions on the build/cache directory and fix ownership (e.g. `chown -R $USER ~/.cache/yay`).
  3. Verify the directory actually contains a PKGBUILD; if not, the clone is corrupt and must be refreshed.
  4. Check disk space and filesystem errors in the wrapped cause.
Defensive patterns

Strategy: fallback

Validate before calling

if _, err := os.Stat(filepath.Join(dir, "PKGBUILD")); err != nil {
    // re-clone the build dir before proceeding
}

Try / catch

var event settingslua.AURPreInstallEvent
event, err := aurPreInstallEvent(base, dir, pkgs, installed, targets)
if err != nil {
    return fmt.Errorf("aur event for %s: %w", base, err)
}

Prevention

When it happens

Trigger: `aurPackageEvent` calls `os.ReadFile(pkgbuildPath)` on `<dir>/PKGBUILD` and the file is missing (incomplete clone), unreadable (permissions), or the path points to a stale/removed build directory.

Common situations: Interrupted AUR clone leaving a directory without PKGBUILD, another user owning ~/.cache/yay contents (root vs user runs), disk cleanup removing build dirs mid-operation, SELinux/AppArmor denying read.

Understand the failure class

Background: "failed to read file", EACCES, ENOENT and "could not read <path>" errors: when a program can't read a file from disk — this error's family across 49 libraries.

Related errors


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

Appendix: source

Thrown at pkg/sync/workdir/aur_preinstall.go:101

func sortedAURBases(pkgbuildDirsByBase map[string]string) []string {
	return slices.Sorted(maps.Keys(pkgbuildDirsByBase))
}

func aurPreInstallEvent(base, path string, packages []settingslua.AURPreInstallPackage,
	installed mapset.Set[string], targets []map[string]*dep.InstallInfo,
) (settingslua.AURPreInstallEvent, error) {
	return aurPackageEvent(settingslua.EventAURPreInstall, base, path, packages, installed, targets)
}

func aurPackageEvent(eventName, base, path string, packages []settingslua.AURPreInstallPackage,
	installed mapset.Set[string], targets []map[string]*dep.InstallInfo,
) (settingslua.AURPreInstallEvent, error) {
	dir, pkgbuildPath, srcinfoPath := aurPreInstallPaths(path)

	pkgbuildBytes, err := os.ReadFile(pkgbuildPath)
	if err != nil {
		return settingslua.AURPreInstallEvent{},
			fmt.Errorf("%s %s: read PKGBUILD: %w", eventName, base, err)
	}

	srcinfo, err := gosrc.ParseFile(srcinfoPath)
	if err != nil {
		return settingslua.AURPreInstallEvent{},
			fmt.Errorf("%s %s: parse .SRCINFO: %w", eventName, base, err)
	}

	if len(packages) == 0 {
		packages = packagesFromSRCINFO(srcinfo)
	}
	slices.SortFunc(packages, func(a, b settingslua.AURPreInstallPackage) int { return cmp.Compare(a.Name, b.Name) })

	return settingslua.AURPreInstallEvent{
		Base:         base,
		Dir:          dir,
		PKGBUILDPath: pkgbuildPath,
		SRCINFOPath:  srcinfoPath,

View on GitHub (pinned to 328f4b4939)