Environment variable composition and activation layer for tools and processes.
envstack is what
.envfiles wish they were when they grew up.
- Hierarchical environment composition
- Explicit precedence and overrides
- Late-bound environment activation
- Shared, policy-driven environments
- Inspectable and deterministic behavior
envstack focuses on configuration and activation, not dependency resolution.
For the core concepts, see docs/index.md.
The easiest way to install:
pip install -U envstackStart by getting the latest default.env example file:
curl -o \
default.env \
https://raw.githubusercontent.com/rsgalloway/envstack/master/examples/default/default.envRunning envstack will launch a new shell session with the resolved environment:
$ envstack
🚀 Launching envstack shell... (CTRL+D or "exit" to quit)
(prod) ~$ echo $ENV
prodTo inspect the unresolved environment (before variable expansion):
$ envstack -u
DEPLOY_ROOT=${ROOT}/${ENV}
ENV=prod
ENVPATH=${DEPLOY_ROOT}/env:${ENVPATH}
HELLO=${HELLO:=world}
LOG_LEVEL=${LOG_LEVEL:=INFO}
PATH=${DEPLOY_ROOT}/bin:${PATH}
PS1=\[\e[32m\](${ENV})\[\e[0m\] \w\$
PYTHONPATH=${DEPLOY_ROOT}/lib/python:${PYTHONPATH}
ROOT=/mnt/pipe
STACK=default$ envstack -r DEPLOY_ROOT
DEPLOY_ROOT=/mnt/pipe/prodenvstack discovers environment definitions via the ENVPATH environment variable.
ENVPATH is to envstack what PATH is to executables:
ENVPATH=/path/to/dev/env:/path/to/prod/envIn this case, environments in dev override or layer on top of environments in prod.
Convert existing .env files to envstack by piping them into envstack:
cat .env | envstack --set -o out.envTo run any command line executable inside of an environment stack, where
[COMMAND] is the command to run:
$ envstack [STACK] -- [COMMAND]For example:
$ envstack -- echo {ENV}
prodExample of injecting environment into a subprocess:
$ echo "console.log('Hello ' + process.env.ENV)" > index.js
$ node index.js
Hello undefined
$ envstack -- node index.js
Hello prod- Design & philosophy →
docs/design.md - Examples & patterns →
docs/examples.md - Tool comparisons →
docs/comparison.md - FAQ & gotchas →
docs/faq.md - API docs →
docs/api.md