{"record":{"id":"8f6b5f614977d960","repo":"denoland/deno","slug":"runner-environment-environment-variable-is-not-set","errorCode":null,"errorMessage":"RUNNER_ENVIRONMENT environment variable is not set","messagePattern":"RUNNER_ENVIRONMENT environment variable is not set","errorType":"exception","errorClass":"AnyError","httpStatus":null,"severity":"error","filePath":"cli/tools/publish/provenance.rs","lineNumber":187,"sourceCode":"      .replace(&format!(\"{}/\", &repo), \"\");\n\n    let (workflow_path, workflow_ref) = if let Some(delimn) = rel_ref.find('@')\n    {\n      let (path, ref_) = rel_ref.split_at(delimn);\n      (path, &ref_[1..])\n    } else {\n      (rel_ref.as_str(), \"\")\n    };\n\n    let server_url = std::env::var(\"GITHUB_SERVER_URL\").map_err(|_| {\n      anyhow!(\"GITHUB_SERVER_URL environment variable is not set\")\n    })?;\n    let github_ref = std::env::var(\"GITHUB_REF\")\n      .map_err(|_| anyhow!(\"GITHUB_REF environment variable is not set\"))?;\n    let github_sha = std::env::var(\"GITHUB_SHA\")\n      .map_err(|_| anyhow!(\"GITHUB_SHA environment variable is not set\"))?;\n    let runner_env = std::env::var(\"RUNNER_ENVIRONMENT\").map_err(|_| {\n      anyhow!(\"RUNNER_ENVIRONMENT environment variable is not set\")\n    })?;\n    let run_id = std::env::var(\"GITHUB_RUN_ID\")\n      .map_err(|_| anyhow!(\"GITHUB_RUN_ID environment variable is not set\"))?;\n    let run_attempt = std::env::var(\"GITHUB_RUN_ATTEMPT\").map_err(|_| {\n      anyhow!(\"GITHUB_RUN_ATTEMPT environment variable is not set\")\n    })?;\n\n    Ok(Self {\n      build_definition: BuildDefinition {\n        build_type: GITHUB_BUILD_TYPE,\n        external_parameters: ExternalParameters {\n          workflow: GhaWorkflow {\n            ref_: workflow_ref.to_string(),\n            repository: format!(\"{}/{}\", server_url, &repo),\n            path: workflow_path.to_string(),\n          },\n        },\n        internal_parameters: InternalParameters {","sourceCodeStart":169,"sourceCodeEnd":205,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/cli/tools/publish/provenance.rs#L169-L205","documentation":"`RUNNER_ENVIRONMENT` (values like `github-hosted` or `self-hosted`) is read into the provenance predicate's run details to identify where the build executed. This error means `deno publish --provenance` reached predicate construction without that variable, i.e. the GitHub Actions environment is incomplete — almost always because the CLI was re-executed in a container or wrapper that dropped runner env vars.","triggerScenarios":"Container actions or `docker run` publish steps that forward only auth vars; environment scrubbing via `env -i`, minimal Docker images with no ENV inheritance; non-GHA CI partially impersonating GitHub Actions.","commonSituations":"Hardened containers that start with an empty env; scripts that build a curated env dict and forget RUNNER_*; moving a working workflow step into a composite/container action.","solutions":["Forward RUNNER_ENVIRONMENT (ideally the whole runner env block: GITHUB_* and RUNNER_*) into the publish subprocess/container.","Keep the publish step directly on the runner rather than inside a stripped container.","If you intentionally publish outside GitHub Actions, remove `--provenance` from the command."],"exampleFix":"# before\ndocker run --rm -e GITHUB_SHA publisher deno publish --provenance\n\n# after\ndocker run --rm \\\n  -e GITHUB_SHA -e GITHUB_REF -e GITHUB_REPOSITORY -e GITHUB_SERVER_URL \\\n  -e GITHUB_RUN_ID -e GITHUB_RUN_ATTEMPT -e RUNNER_ENVIRONMENT \\\n  -e ACTIONS_ID_TOKEN_REQUEST_URL -e ACTIONS_ID_TOKEN_REQUEST_TOKEN \\\n  publisher deno publish --provenance","handlingStrategy":"validation","validationCode":"const provenanceVars = ['GITHUB_REPOSITORY', 'GITHUB_SERVER_URL',\n  'GITHUB_REF', 'GITHUB_SHA', 'RUNNER_ENVIRONMENT', 'GITHUB_RUN_ID',\n  'GITHUB_RUN_ATTEMPT'];\nif (provenanceVars.some((k) => !Deno.env.get(k))) {\n  const args = ['publish']; // no --provenance\n}","typeGuard":null,"tryCatchPattern":"try {\n  await runDeno(['publish', '--provenance']);\n} catch (e) {\n  if (String(e.message).includes('RUNNER_ENVIRONMENT')) {\n    // runner metadata was dropped by a wrapper; restore env inheritance and retry\n  }\n}","preventionTips":["Forward RUNNER_* vars along with GITHUB_* when containerizing publish steps.","Never build a curated minimal env for provenance; it needs the full runner context.","Keep the publish step on the runner when provenance is required."],"tags":["publish","provenance","github-actions","environment","slsa"],"backgroundTag":"missing-env-var","analyzedSha":"9ad36f7a2cce60488e6ec52283efb32efddaf93a","analyzedAt":"2026-08-20T13:07:44.778Z","contentChangedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}