pulumi/pulumi · error

only one of --stack or argument stack name may be specified,

Error message

only one of --stack or argument stack name may be specified, not both

What it means

Validation error in `pulumi stack select`: the stack name was supplied twice — once via the --stack flag and once as a positional argument. The CLI refuses ambiguity rather than guessing which source wins.

Source

Thrown at pkg/cmd/pulumi/stack/stack_select.go:69

			ws := pkgWorkspace.Instance
			opts := display.Options{
				Color: cmdutil.GetGlobalColorization(),
			}

			// Try to read the current project
			project, root, err := ws.ReadProject("")
			if err != nil && !errors.Is(err, workspace.ErrProjectNotFound) {
				return err
			}

			b, err := backend.CurrentBackend(ctx, ws, backend.DefaultLoginManager, project, opts)
			if err != nil {
				return err
			}

			if len(args) > 0 {
				if stack != "" {
					return errors.New("only one of --stack or argument stack name may be specified, not both")
				}

				stack = args[0]
			}

			if stack == "" && !cmdutil.Interactive() {
				return backenderr.NoStackSelectedError{}
			}

			if stack != "" {
				// A stack was given, ask the backend about it.
				stackRef, stackErr := b.ParseStackReference(stack)
				if stackErr != nil {
					return stackErr
				}

				s, stackErr := b.GetStack(ctx, stackRef)
				if stackErr != nil {

View on GitHub (pinned to 793f7b2e16)

Solutions

  1. Supply the stack name only once — either as the argument or via --stack, not both
  2. Remove the redundant --stack flag if the positional name is intended
  3. Fix the wrapping script so it passes exactly one of the two

Example fix

// before
pulumi stack select --stack prod prod
// after
pulumi stack select prod
Defensive patterns

Strategy: validation

Validate before calling

if [[ -n "$STACK_FLAG" && -n "$STACK_ARG" ]]; then echo "pass only one of --stack or positional stack name" >&2; exit 1; fi

Prevention

When it happens

Trigger: Running e.g. `pulumi stack select -s prod prod` or `pulumi stack select my-stack --stack my-stack`. Any case where len(args) > 0 and the stack flag is non-empty triggers it.

Common situations: Scripts that append a stack name while also setting --stack; muscle memory mixing `pulumi stack select <name>` with the --stack convention from other commands.

Related errors


AI-assisted analysis of pulumi/pulumi@793f7b2e16 (2026-08-31). Data as JSON: /api/errors/07cae9278cad22e3. Report an issue: GitHub.