{
  "slug": "cargo-lambda-deploy-merges-environment-variables-with-merge-env-db814b348311",
  "title": "cargo-lambda deploy merges environment variables with --merge-env",
  "tools": [
    "cargo-lambda"
  ],
  "tags": [
    "agent"
  ],
  "introduced_at": "2026-02-15T19:11:15.000Z",
  "announced_at": "2026-02-15T19:11:15.000Z",
  "effective_at": null,
  "date_basis": "source-publication",
  "status": "unknown",
  "how": {
    "incantation": "When deploying a function and remote environment variables must be preserved, run `cargo lambda deploy --merge-env` with the function name and the environment variables to add or update. Existing remote variables remain; local values take precedence for duplicates.",
    "examples": [
      "cargo lambda deploy --merge-env --env-var NEW_VAR=VALUE <function-name>",
      "cargo lambda deploy --merge-env --env-vars FOO=BAR,BAZ=QUX <function-name>",
      "cargo lambda deploy --merge-env --env-file <path> <function-name>"
    ],
    "gotchas": [
      "Version: v1.9.0",
      "--merge-env: Preserve existing remote environment variables; variables in local configuration are added or updated, with local values taking precedence for duplicates.",
      "--env-var KEY=VALUE: Set environment variables using KEY=VALUE. May be repeated; docs say it overrides --env-vars and cannot be combined with it.",
      "--env-vars KEY=VALUE,...: Set environment variables from a comma-separated list. Cannot be combined with --env-var.",
      "--env-file <path>: Read environment variables from a file with one KEY=VALUE per line.",
      "function-name (required): Function name argument for the deploy command.",
      "merge_env: Cargo.toml deploy metadata boolean; `true` enables merging and the default is `false`.",
      "Prerequisite: Build the function binary before deploying; deploy fails if it cannot find the binary.",
      "Prerequisite: AWS account permissions for Lambda operations including `lambda:GetFunction`, `lambda:CreateFunction`, and `lambda:UpdateFunctionCode`; an IAM execution role with Lambda privileges is also required.",
      "Merging is enabled by the `--merge-env` flag or `merge_env = true`; the configuration default is false.",
      "When a variable is specified remotely and in configuration, the local value takes precedence."
    ]
  },
  "why_it_matters": "Deploy a function while preserving environment variables managed outside Cargo Lambda.",
  "before": "Without `--merge-env`, deployment overwrites existing remote environment variables with the variables specified in configuration.",
  "sources": [
    "https://github.com/cargo-lambda/cargo-lambda/releases/tag/v1.9.0",
    "https://github.com/cargo-lambda/cargo-lambda/pull/910",
    "https://github.com/cargo-lambda/cargo-lambda/blob/v1.9.0/docs/commands/deploy.md"
  ],
  "rank": 0.96032,
  "judge": {
    "publish": true,
    "judge_model": "codex-cli/gpt-6-luna+typesafe/jev-1.13.0",
    "prompt_version": "extract-v7+enrich-v2+judge-v2x3+jev-publish-v1"
  },
  "review_state": "approved",
  "provenance": {
    "run_id": "wave1b-tools-20261017",
    "verdict_id": "wave1b-tools-20261017:wave1b-tools-20261017-755fa2cb01364297-4:gate",
    "evidence_hash": "aa219556fc6395aa6acfa392dbfa7af6b7cb3cfcb85a92922d99c616f256163a"
  },
  "review": {
    "draft_hash": "693c8ac8c8811fd23f099c7ae55dfb77139dd20e3e1cb9d5e490ea7c2a3d703f",
    "reviewer": "publication-gate",
    "reviewed_at": "2026-10-07T00:00:00.000Z",
    "decision": "wave1b-tools-20261017:gate",
    "reason": "3 of 3 judge runs approved with p_yes >= 0.9 (mean 0.96 >= 0.9; 2 needed) and Jev gave 0.79 (>= 0.6 needed)."
  }
}
