grafana/k6 · error
the --local-execution flag is not compatible with the --exit
Error message
the --local-execution flag is not compatible with the --exit-on-running flag
What it means
The `k6 cloud run` preRun hook rejects combining --local-execution with --exit-on-running. In local-execution mode the test runs in this process, so the cloud-only 'exit when the run reaches Running state' behavior is meaningless and would silently never trigger. The error carries exit code InvalidConfig (104) via errext.WithExitCodeIfNone.
Source
Thrown at internal/cmd/cloud_run.go:109
"the k6 cloud run command expects a single argument consisting in either a path to a script or "+
"archive file, or the \"-\" symbol indicating the script or archive should be read from stdin",
),
PreRunE: cloudRunCmd.preRun,
RunE: cloudRunCmd.run,
}
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,View on GitHub (pinned to 93accf6570)
Solutions
- Remove --exit-on-running from the command when using --local-execution
- If you need the old cloud-execution behavior, drop --local-execution instead
- Audit shared flag variables in CI wrappers so mutually exclusive flags are not always injected
Example fix
# before k6 cloud run --local-execution --exit-on-running script.js # after k6 cloud run --local-execution script.js
Defensive patterns
Strategy: validation
Validate before calling
// wrapper-level guard before shelling out to k6
if localExecution && strings.Join(os.Args, " ") != "" {
for _, a := range os.Args {
if a == "--exit-on-running" || strings.HasPrefix(a, "--exit-on-running=") {
log.Fatal("--exit-on-running cannot be combined with --local-execution")
}
}
} Prevention
- Build cloud-run flag sets per execution mode instead of one shared variable
- Document flag compatibility in the CI job template
- Check exit code 104 (InvalidConfig) in wrappers to fail fast on flag misuse
When it happens
Trigger: Invoking `k6 cloud run --local-execution --exit-on-running ...` (or setting the flag to any value, including false, since only Flags().Changed matters).
Common situations: CI wrappers that pass a fixed set of cloud flags to every invocation; migrating an existing `k6 cloud --exit-on-running` pipeline to local execution; shell scripts reusing a shared FLAGS variable.
Related errors
- the --local-execution flag is not compatible with the --show
- the --linger flag can only be used in conjunction with the -
- the --no-cloud-secrets flag can only be used in conjunction
- the --no-cloud-logs flag can only be used in conjunction wit
- stack value is required but it was not passed or is empty
AI-assisted analysis of grafana/k6@93accf6570 (2026-08-15).
Data as JSON: /api/errors/1af80ccf50f926c7.
Report an issue: GitHub.