Manage and inject environment variables from multiple sources with precedence rules.
go install github.com/yourusername/envchain@latestOr build from source:
git clone https://github.com/yourusername/envchain.git && cd envchain && go build ./...Define your sources in an envchain.yaml file and run any command with the resolved environment:
sources:
- type: dotenv
path: .env.local
- type: vault
path: secret/myapp
- type: env# Inject resolved variables into a command
envchain run -- ./myapp
# Print resolved environment without running a command
envchain dump
# Specify a custom config file
envchain --config ./config/envchain.yaml run -- npm startSources are merged in order, with later sources taking higher precedence. Variables already set in the environment can be configured to override or defer to upstream sources.
| Field | Description |
|---|---|
type |
Source type (dotenv, env, vault, ssm) |
path |
Path or identifier for the source |
optional |
Skip source if unavailable |
MIT — see LICENSE for details.