Environment Variables
biwa can forward local environment variables to the remote process (inheritance), send explicit values, and expand wildcard rules.
Config Keys
| Key | Type | Default | Description |
|---|---|---|---|
env.vars | array / table | [] | Environment variables to inherit, match, exclude, or set |
env.forward_method | string | "export" | Use "export" or "setenv" when sending variables |
Supported Config Forms
Array
[env]
vars = ["NODE_ENV", "API_KEY=secret", { DEBUG = "1" }]
forward_method = "export"Table
[env]
forward_method = "export"
[env.vars]
NODE_ENV = true
API_KEY = "secret"Array Of Inline Tables
[env]
vars = [{ NODE_ENV = "production" }, { API_KEY = "secret" }]NAMEorNAME = trueinherits the local value from your machine to the remote process.NAME=valueorNAME = "value"sends a literal value.
Wildcards And Negation
All env.vars forms (array, table, array of tables) support wildcard rules:
[env]
vars = ["NODE_*", "!*PATH"]*matches zero or more characters in an environment variable name.NODE_*inherits all local variables whose names start withNODE_.!*PATHremoves already-selected variables whose names end inPATH.- Prefer targeted patterns like
NODE_*,AWS_*, orCARGO_*. - Avoid mixing catch-all
*with explicit variable names in the sameenv.varssection; if you need broad matching, use specific prefixes plus exclusions instead.
Evaluation Order
Regardless of the config form or declaration order, rules are always evaluated deterministically:
- Inherit patterns — wildcard matches like
NODE_* = trueexpand first. - Exact specifications — explicit names like
NODE_ENV = trueorAPI_KEY = "secret"override inherited values. - Exclusions — removal rules like
!*PATH = trueapply last.
This means an explicit value always takes priority over a pattern-inherited one. For example, with NODE_* = true and NODE_ENV = "prod", even if the local machine has NODE_ENV = "dev", the result will be NODE_ENV = "prod".
BIWA_ENV_VARS
You can add environment variables from the local shell without touching config:
BIWA_ENV_VARS=NODE_ENV biwa run --skip-sync env
BIWA_ENV_VARS=NODE_ENV=prod biwa run --skip-sync env
BIWA_ENV_VARS=NODE_* biwa run --skip-sync envBIWA_ENV_VARS=NODE_ENVinherits a local value.BIWA_ENV_VARS=NODE_ENV=prodsets a literal value.BIWA_ENV_VARS=NODE_*uses wildcard inheritance.
biwa run --env
biwa run supports repeated flags, such as names, wildcards, and KEY=value pairs:
biwa run --env NODE_ENV --env API_KEY env
biwa run --env NODE_ENV=prod --env API_KEY env
biwa run --env NODE_* --env '!*PATH' envCLI --env values override config-defined env vars with the same name.
Forwarding Methods
exportprepends shell-safeexport KEY=VALUEstatements to the remote command. This is the default and most compatible mode.setenvuses SSHsetenvrequests before running the command.
UNSW CSE
UNSW CSE does not support SSH setenv, so use env.forward_method = "export" there.
Environment-Dependent Variables
biwa warns when you inherit machine-specific variables such as:
PATH,LD_LIBRARY_PATH,LIBRARY_PATHHOME,PWD,OLDPWDPYTHONHOME,PYTHONPATH,VIRTUAL_ENV,CONDA_PREFIXNODE_PATH,NPM_CONFIG_PREFIXJAVA_HOME,CLASSPATHGOPATH,GOBIN,GOMODCACHEGEM_HOME,GEM_PATH,BUNDLE_PATH,BUNDLE_BINCARGO_HOME,RUSTUP_HOMEPHP_INI_SCAN_DIR
Those values often differ between your local machine and the remote host.
Security
Inherited variables are injected into the remote process environment. Be careful when sending secrets, and prefer only the variables you actually need.