{"record":{"id":"b46cb4f65521d353","repo":"grafana/k6","slug":"the-linger-flag-can-only-be-used-in-conjunction","errorCode":null,"errorMessage":"the --linger flag can only be used in conjunction with the --local-execution flag","messagePattern":"the --linger flag can only be used in conjunction with the --local-execution flag","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cmd/cloud_run.go","lineNumber":126,"sourceCode":"\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,\n\t\t)\n\t}\n\n\tif c.noCloudSecrets {\n\t\treturn errext.WithExitCodeIfNone(\n\t\t\tfmt.Errorf(\"the --no-cloud-secrets flag can only be used in conjunction with the --local-execution flag\"),\n\t\t\texitcodes.InvalidConfig,\n\t\t)\n\t}\n\n\tif c.noCloudLogs {\n\t\treturn errext.WithExitCodeIfNone(\n\t\t\tfmt.Errorf(\"the --no-cloud-logs flag can only be used in conjunction with the --local-execution flag\"),\n\t\t\texitcodes.InvalidConfig,\n\t\t)\n\t}\n","sourceCodeStart":108,"sourceCodeEnd":144,"githubUrl":"https://github.com/grafana/k6/blob/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/cmd/cloud_run.go#L108-L144","documentation":"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).","triggerScenarios":"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.","commonSituations":"Porting `k6 run --linger` habits or scripts to `k6 cloud run`; CI base commands that append --linger unconditionally.","solutions":["Add --local-execution to the command when you want --linger","Or remove --linger if you actually want cloud execution","Check environment wrappers/scripts that inject --linger automatically"],"exampleFix":"# before\nk6 cloud run --linger script.js\n# after\nk6 cloud run --local-execution --linger script.js","handlingStrategy":"validation","validationCode":"// ensure mode-dependent flags travel together\nif slices.Contains(args, \"--linger\") && !slices.Contains(args, \"--local-execution\") {\n    log.Fatal(\"--linger requires --local-execution\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Group --linger, --no-usage-report, --no-archive-upload, --no-cloud-secrets, --no-cloud-logs as local-execution-only flags in shared templates","Validate the full flag combination in wrappers before running k6","Watch for exit code 104 to catch incompatible flag pairs early"],"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"}