env

Manage session-level environment variables. Variables set with env are applied to every contree run automatically. Per-run -e flags override session env vars with the same key.

Examples

# Set PATH after installing tools
contree env PATH=/root/.cargo/bin:/usr/local/bin:/usr/bin:/bin:/sbin

# Set multiple variables
contree env DEBUG=1 DB_HOST=localhost

# List current session env
contree env

# Unset variables
contree env -d PATH
contree env -d DEBUG DB_HOST

# Per-run -e overrides session env
contree run -e DEBUG=0 -- ./app

Help output

$ contree env --help usage: contree env [-h] [-U] [KEY=VALUE ...] Manage session environment variables. Session env vars are applied to every `contree run` automatically. Per-run `-e` flags override session env vars with the same key. positional arguments:   KEY=VALUE           Environment variables to set (or keys to delete with -d) options:   -h, --help          show this help message and exit   -U, --delete, --rm  Unset the specified environment variables examples:   contree env                                  list session env vars   contree env PATH=/root/.cargo/bin:$PATH      set PATH   contree env DEBUG=1 DB_HOST=localhost         set multiple   contree env -d PATH                          unset PATH   contree env -d PATH DEBUG                    unset multiple agent note:   Before using this command in an automated workflow, read:     contree agent

Behavior

Session env vars are stored in SQLite per session. They persist across terminal restarts (when using -S or CONTREE_SESSION).

When contree run builds the payload, it merges:

  1. Session env vars (base)

  2. Per-run -e flags (override)

Deleting a session (session delete) removes its env vars.

Values with = in them work correctly — only the first = is the separator: contree env CMD=a=b=c sets CMD to a=b=c.