grafana/k6 · error

the --linger flag can only be used in conjunction with the -

Error message

the --linger flag can only be used in conjunction with the --local-execution flag

What it means

The `k6 cloud run` preRun hook rejects --linger without --local-execution. Lingering keeps the local REST API server alive after the test ends; that server only exists in local-execution mode, so the flag is meaningless for cloud-executed tests. The error exits with code InvalidConfig (104).

Source

Thrown at internal/cmd/cloud_run.go:126

			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,
		)
	}

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

View on GitHub (pinned to 93accf6570)

Solutions

  1. Add --local-execution to the command when you want --linger
  2. Or remove --linger if you actually want cloud execution
  3. Check environment wrappers/scripts that inject --linger automatically

Example fix

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

Strategy: validation

Validate before calling

// ensure mode-dependent flags travel together
if slices.Contains(args, "--linger") && !slices.Contains(args, "--local-execution") {
    log.Fatal("--linger requires --local-execution")
}

Prevention

When it happens

Trigger: Invoking `k6 cloud run --linger ...` (or plain `k6 cloud` style usage) without --local-execution; also when the flag is inherited from a wrapper that always sets it.

Common situations: Porting `k6 run --linger` habits or scripts to `k6 cloud run`; CI base commands that append --linger unconditionally.

Related errors


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