Jguer/yay · error

only one operation may be used at a time

Error message

only one operation may be used at a time

What it means

addOP in pkg/settings/parser/parser.go enforces that an Arguments struct holds exactly one pacman-style operation (e.g. -S, -Q, -R). If a.Op is already set and another operation is passed, it rejects the parse with 'only one operation may be used at a time'. This mirrors pacman's CLI contract where operations are mutually exclusive.

Solutions

  1. Remove all but one operation flag from the command line (keep -S OR -Q, not both).
  2. Split into separate invocations, e.g. run 'yay -Sy' then 'yay -Qi pkg'.
  3. Check shell variables/aliases that prepend extra operation flags before constructing the Arguments.
  4. Fix programmatic callers to check a.Op != "" before calling AddArg with another operation.

Example fix

// before
args.Parse() with: yay -Sy -Qi linux
// after
yay -Sy && yay -Qi linux
Defensive patterns

Strategy: validation

Validate before calling

ops := []string{"S", "Q", "R", "U", "F", "T"}
count := 0
for _, a := range argv {
    if slices.Contains(ops, strings.TrimLeft(a, "-")) {
        count++
    }
}
if count > 1 {
    return errors.New("pass only one pacman operation per invocation")
}

Try / catch

err := args.Parse() // or AddArg(op)
if err != nil {
    if strings.Contains(err.Error(), "only one operation may be used") {
        return usageError("combine incompatible operations; split into separate commands")
    }
    return err
}

Prevention

When it happens

Trigger: Calling AddArg/parseShortOption/parseLongOption with a second operation flag while one is already recorded, e.g. adding both 'S' and 'Q' (via addParam -> isOp -> addOP).

Common situations: Command lines like 'yay -Sy -Qi pkg' or programmatically appending a second op to an Arguments struct; shell scripts concatenating pacman flags from different commands; typos turning an option into an operation.

Understand the failure class

Background: "mutually exclusive" flag errors: what "can't supply both nx and xx", "--raw is not compatible with -i" and "cannot be used with" mean, and how to fix them — this error's family across 29 libraries.

Related errors


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

Appendix: source

Thrown at pkg/settings/parser/parser.go:163

		case a.ExistsArg("g", "groups"):
			return false
		case a.ExistsArg("i", "info"):
			return false
		case a.ExistsArg("c", "clean") && mode == ModeAUR:
			return false
		}

		return true
	case "U", "upgrade":
		return true
	default:
		return false
	}
}

func (a *Arguments) addOP(op string) error {
	if a.Op != "" {
		return errors.New(gotext.Get("only one operation may be used at a time"))
	}

	a.Op = op

	return nil
}

func (a *Arguments) addParam(option, arg string) error {
	if !isArg(option) {
		return errors.New(gotext.Get("invalid option '%s'", option))
	}

	if isOp(option) {
		return a.addOP(option)
	}

	a.CreateOrAppendOption(option, strings.Split(arg, ",")...)

View on GitHub (pinned to 328f4b4939)