{"record":{"id":"ee2c63680b228a96","repo":"Jguer/yay","slug":"error-merging-s-s","errorCode":null,"errorMessage":"error merging %s: %s","messagePattern":"error merging (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/sync/workdir/merge.go","lineNumber":24,"sourceCode":"\n\t\"github.com/leonelquinteros/gotext\"\n\n\t\"github.com/Jguer/yay/v13/pkg/settings/exe\"\n)\n\nfunc gitMerge(ctx context.Context, cmdBuilder exe.ICmdBuilder, dir string) error {\n\t_, stderr, err := cmdBuilder.Capture(\n\t\tcmdBuilder.BuildGitCmd(ctx,\n\t\t\tdir, \"reset\", \"--hard\", \"HEAD\"))\n\tif err != nil {\n\t\treturn errors.New(gotext.Get(\"error resetting %s: %s\", dir, stderr))\n\t}\n\n\t_, stderr, err = cmdBuilder.Capture(\n\t\tcmdBuilder.BuildGitCmd(ctx,\n\t\t\tdir, \"merge\", \"--no-edit\", \"--ff\"))\n\tif err != nil {\n\t\treturn errors.New(gotext.Get(\"error merging %s: %s\", dir, stderr))\n\t}\n\n\treturn nil\n}\n\nfunc mergePkgbuilds(ctx context.Context, cmdBuilder exe.ICmdBuilder, pkgbuildDirs map[string]string) error {\n\tfor _, dir := range pkgbuildDirs {\n\t\terr := gitMerge(ctx, cmdBuilder, dir)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil\n}\n","sourceCodeStart":6,"sourceCodeEnd":40,"githubUrl":"https://github.com/Jguer/yay/blob/328f4b4939fb35f38c2f7c7ce3b8638a839bafa5/pkg/sync/workdir/merge.go#L6-L40","documentation":"This error is thrown by gitMerge in pkg/sync/workdir/merge.go when a `git merge --no-edit --ff` command executed against a diff directory fails. It wraps the git stderr into a localized message identifying which directory failed to merge. It is raised while merging saved PKGBUILD diffs during package sync.","triggerScenarios":"Running yay sync/install where mergePkgbuilds calls gitMerge and the underlying `git merge --no-edit --ff` exits non-zero (e.g. merge conflicts in the diff repo, corrupt or dirty worktree, missing git binary).","commonSituations":"Users with local modifications to the yay diff repository hit fast-forward merge conflicts; corrupted ~/.local/share/yay diffs after interrupted syncs; git not installed or misconfigured (user.name/email policies blocking merge).","solutions":["Read the stderr embedded in the error to see the git failure reason","Delete the affected diff directory (e.g. ~/.local/share/yay/<pkg>) so it is recreated from scratch","Run `git -C <dir> status` / `git -C <dir> merge --abort` to clean a conflicted worktree","Ensure git is installed and configured","Re-run the yay operation"],"exampleFix":"// before: conflicted diff dir blocks every sync\n$ yay -S linux\nerror merging /home/u/.local/share/yay/linux: Auto-merging PKGBUILD\n// after: reset the diff repo\n$ rm -rf ~/.local/share/yay/linux && yay -S linux","handlingStrategy":"try-catch","validationCode":"diffDir=\"$HOME/.local/share/yay/$pkg\"\nif [ -d \"$diffDir/.git\" ] && ! git -C \"$diffDir\" diff --quiet; then\n  echo \"dirty diff repo for $pkg; resetting\"; rm -rf \"$diffDir\"\nfi\ngit --version >/dev/null || { echo 'git not installed'; exit 1; }","typeGuard":"func isGitMergeError(err error) (dir string, ok bool) {\n\tif err == nil { return \"\", false }\n\tmsg := err.Error()\n\tif strings.HasPrefix(msg, \"error merging \") {\n\t\tif i := strings.Index(msg, \": \"); i >= 0 {\n\t\t\treturn strings.TrimPrefix(msg[:i], \"error merging \"), true\n\t\t}\n\t}\n\treturn \"\", false\n}","tryCatchPattern":"if err := runYaySync(pkg); err != nil {\n\tif dir, ok := isGitMergeError(err); ok {\n\t\tos.RemoveAll(filepath.Join(diffRoot, dir)) // reset diff repo\n\t\treturn runYaySync(pkg) // retry clean\n\t}\n\treturn err\n}","preventionTips":["Avoid hand-editing files inside the yay diff directories","Periodically clean ~/.local/share/yay if syncs repeatedly conflict","Keep git installed and configured on the system","Retry the operation once after resetting a conflicted diff repo"],"tags":["git","merge","sync","pkgbuild"],"backgroundTag":"git-command-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"}