{"record":{"id":"1af80ccf50f926c7","repo":"grafana/k6","slug":"the-local-execution-flag-is-not-compatible-with","errorCode":null,"errorMessage":"the --local-execution flag is not compatible with the --exit-on-running flag","messagePattern":"the --local-execution flag is not compatible with the --exit-on-running flag","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cmd/cloud_run.go","lineNumber":109,"sourceCode":"\t\t\t\"the k6 cloud run command expects a single argument consisting in either a path to a script or \"+\n\t\t\t\t\"archive file, or the \\\"-\\\" symbol indicating the script or archive should be read from stdin\",\n\t\t),\n\t\tPreRunE: cloudRunCmd.preRun,\n\t\tRunE:    cloudRunCmd.run,\n\t}\n\n\tthisCmd.Flags().SortFlags = false\n\tthisCmd.Flags().AddFlagSet(cloudRunCmd.flagSet())\n\tthisCmd.Flags().AddFlagSet(cloudCmd.flagSet())\n\n\treturn thisCmd\n}\n\nfunc (c *cmdCloudRun) preRun(cmd *cobra.Command, args []string) error {\n\tif c.localExecution {\n\t\tif cmd.Flags().Changed(\"exit-on-running\") {\n\t\t\treturn errext.WithExitCodeIfNone(\n\t\t\t\tfmt.Errorf(\"the --local-execution flag is not compatible with the --exit-on-running flag\"),\n\t\t\t\texitcodes.InvalidConfig,\n\t\t\t)\n\t\t}\n\n\t\tif cmd.Flags().Changed(\"show-logs\") {\n\t\t\treturn errext.WithExitCodeIfNone(\n\t\t\t\tfmt.Errorf(\"the --local-execution flag is not compatible with the --show-logs flag\"),\n\t\t\t\texitcodes.InvalidConfig,\n\t\t\t)\n\t\t}\n\n\t\treturn nil\n\t}\n\n\tif c.linger {\n\t\treturn errext.WithExitCodeIfNone(\n\t\t\tfmt.Errorf(\"the --linger flag can only be used in conjunction with the --local-execution flag\"),\n\t\t\texitcodes.InvalidConfig,","sourceCodeStart":91,"sourceCodeEnd":127,"githubUrl":"https://github.com/grafana/k6/blob/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/cmd/cloud_run.go#L91-L127","documentation":"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.","triggerScenarios":"Invoking `k6 cloud run --local-execution --exit-on-running ...` (or setting the flag to any value, including false, since only Flags().Changed matters).","commonSituations":"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.","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"],"exampleFix":"# before\nk6 cloud run --local-execution --exit-on-running script.js\n# after\nk6 cloud run --local-execution script.js","handlingStrategy":"validation","validationCode":"// wrapper-level guard before shelling out to k6\nif localExecution && strings.Join(os.Args, \" \") != \"\" {\n    for _, a := range os.Args {\n        if a == \"--exit-on-running\" || strings.HasPrefix(a, \"--exit-on-running=\") {\n            log.Fatal(\"--exit-on-running cannot be combined with --local-execution\")\n        }\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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"],"tags":["cli","flags","cloud-run","invalid-config"],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}