From be5509d53773f0e9ec3c751ede6070a630b4a9e3 Mon Sep 17 00:00:00 2001 From: Marco Walz Date: Thu, 18 Jun 2026 09:16:58 +0200 Subject: [PATCH] fix(AGENTS.md): canister env vars are settings, not WASM metadata MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ic_cdk::api::env_var_value / Runtime.envVar read canister environment variables — these are canister settings applied by icp-cli at deploy time, distinct from WASM metadata (which is used for e.g. candid:service). Co-Authored-By: Claude Sonnet 4.6 --- AGENTS.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 3d8f94e528..ff65903925 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -180,7 +180,7 @@ environments: ICP_LEDGER_CANISTER_ID: "ryjl3-tyaaa-aaaaa-aaaba-cai" ``` -icp-cli injects these as WASM metadata before `cargo build`. Read them at **runtime** via `ic_cdk::api::env_var_value("ICP_LEDGER_CANISTER_ID")` (Rust) or `Runtime.envVar("ICP_LEDGER_CANISTER_ID")` (Motoko) — not via `env!()` or `std::env::var()`. +icp-cli applies these as canister settings at deploy time. Read them at **runtime** via `ic_cdk::api::env_var_value("ICP_LEDGER_CANISTER_ID")` (Rust) or `Runtime.envVar("ICP_LEDGER_CANISTER_ID")` (Motoko) — not via `env!()` or `std::env::var()`. **When to apply this pattern**: judge whether staging/production environments make sense for the specific example. Apply it when the example hardcodes an external canister principal that has a test counterpart (TESTICP, testnet URLs, staging governance canisters, etc.). Skip it for self-contained examples that don't call external canisters. @@ -274,7 +274,7 @@ Always use `ic-cdk = "0.20"` unless a dependency forces a lower version. When us ### Environment variables in Rust canisters -Use `ic_cdk::api::env_var_value("VAR_NAME")` to read icp-cli-injected variables at **runtime** from WASM metadata. This is the Rust equivalent of `Runtime.envVar` in Motoko: +Use `ic_cdk::api::env_var_value("VAR_NAME")` to read canister environment variables at **runtime**. These are canister settings applied by icp-cli at deploy time, not WASM metadata. This is the Rust equivalent of `Runtime.envVar` in Motoko: ```rust fn ledger_principal() -> Principal {