grafana/k6 · error

the --local-execution flag is not compatible with the --show

Error message

the --local-execution flag is not compatible with the --show-logs flag

What it means

The `k6 cloud run` preRun hook rejects combining --local-execution with --show-logs. Cloud log streaming is a cloud-execution feature; with --local-execution the test's logs are already printed locally, so the flag contradicts the mode. The error exits with code InvalidConfig (104).

Source

Thrown at internal/cmd/cloud_run.go:116

	thisCmd.Flags().SortFlags = false
	thisCmd.Flags().AddFlagSet(cloudRunCmd.flagSet())
	thisCmd.Flags().AddFlagSet(cloudCmd.flagSet())

	return thisCmd
}

func (c *cmdCloudRun) preRun(cmd *cobra.Command, args []string) error {
	if c.localExecution {
		if cmd.Flags().Changed("exit-on-running") {
			return errext.WithExitCodeIfNone(
				fmt.Errorf("the --local-execution flag is not compatible with the --exit-on-running flag"),
				exitcodes.InvalidConfig,
			)
		}

		if cmd.Flags().Changed("show-logs") {
			return errext.WithExitCodeIfNone(
				fmt.Errorf("the --local-execution flag is not compatible with the --show-logs flag"),
				exitcodes.InvalidConfig,
			)
		}

		return nil
	}

	if c.linger {
		return errext.WithExitCodeIfNone(
			fmt.Errorf("the --linger flag can only be used in conjunction with the --local-execution flag"),
			exitcodes.InvalidConfig,
		)
	}

	if c.noCloudSecrets {
		return errext.WithExitCodeIfNone(
			fmt.Errorf("the --no-cloud-secrets flag can only be used in conjunction with the --local-execution flag"),
			exitcodes.InvalidConfig,

View on GitHub (pinned to 93accf6570)

Solutions

  1. Remove --show-logs when using --local-execution; local logs are shown by default
  2. Or drop --local-execution to keep streaming cloud logs
  3. Update shared CI flag sets to branch on execution mode

Example fix

# before
k6 cloud run --local-execution --show-logs script.js
# after
k6 cloud run --local-execution script.js
Defensive patterns

Strategy: validation

Validate before calling

// wrapper-level guard before invoking k6
for _, a := range os.Args {
    if a == "--show-logs" || strings.HasPrefix(a, "--show-logs=") {
        if localExecution {
            log.Fatal("--show-logs cannot be combined with --local-execution")
        }
    }
}

Prevention

When it happens

Trigger: Invoking `k6 cloud run --local-execution --show-logs ...` — the check fires whenever the flag was changed, regardless of the value given.

Common situations: Copy-pasting cloud flags from an existing `k6 cloud` pipeline into the new local-execution flow; CI templates that always pass --show-logs/--no-show-logs.

Related errors


AI-assisted analysis of grafana/k6@93accf6570 (2026-08-15). Data as JSON: /api/errors/edcde17b6a3598db. Report an issue: GitHub.