easyenv loads a directory's .env file into your shell the moment you cd into it, and unloads it the moment you cd back out. That's the whole feature.
$ cd ~/projects/api
$ echo $DATABASE_URL
postgres://localhost/api_dev
$ cd ~/projects/frontend
$ echo $DATABASE_URL
No .envrc, no per-directory trust prompts, no leftover variables from the last project you were in. If a parent directory also has a .env, easyenv loads that too — the child directory's values win on conflicting keys, everything else from the parent still comes through. You install it once and forget it's there.
📖 Full documentation, tutorials, and the CLI reference: chrisbcole.me/easyenv
We provide a convenience script to automate installation - the script just picks up your platform, finds the latest release, downloads it, puts it in a folder of your choosing (~/.local/bin by default) and then appends a line to your shell configuration (either bash or zsh) after asking for confirmation. If you don't trust the script, please do read it, it's fairly straightforward.
curl -fsSL https://raw.githubusercontent.com/Chris1221/easyenv/main/install.sh | bashRestart your shell, and you should be able to read environmental variables without any configuration
# For example, make a simple environmental configuration
$ mkdir .test
$ echo "TEST=test" > .test/.env
# Outside the directory, this will be empty.
$ echo $TEST
# But inside the directory, the environmental variables will be populated
$ cd .test; echo $TEST
test
# Don't forget to clean up...
$ rm -r .test install.sh is a plain, readable shell script — review it before piping it to bash if you'd like. Prebuilt archives for Linux (x86_64/aarch64, gnu/musl), macOS (Intel/Apple Silicon), and Windows are also on the releases page if you'd rather install manually, and cargo install --path . works from a clone. See the installation guide and quickstart tutorial for the full walkthrough.
Against direnv, autoenv, and the three other tools this project benchmarks itself against (shadowenv from Shopify, mise from jdx, and zsh-autoenv):
| easyenv | direnv | autoenv | shadowenv | mise | zsh-autoenv | sourcing .env by hand |
|
|---|---|---|---|---|---|---|---|
Loads .env automatically, no boilerplate |
✅ | ❌ — needs an .envrc that explicitly calls dotenv |
✅ | ❌ — config is Shadowlisp (.shadowenv.d/*.lisp), not .env |
❌ — needs mise.toml (can _.source a .env, but still needs the config file) |
❌ — config is .autoenv.zsh, an actual zsh script |
❌ |
Unloads automatically on cd out |
✅ | ✅ | ❌ — needs .env.leave + opt-in |
✅ | ✅ | ✅ | ❌ |
| No per-directory trust/allow step | ✅ | ❌ — requires direnv allow the first time (and again on every edit) |
❌ — prompts interactively the first time a .env is new or changed (bypassable via AUTOENV_ASSUME_YES) |
❌ — requires shadowenv trust |
❌ — requires mise trust (auto-trusted in detected CI by default) |
❌ — same whitelist-prompt model as autoenv | n/a |
What a hostile .env in a cloned repo can do |
set inert variables only — ~150 dangerous names denied by default | nothing, without an explicit direnv allow |
nothing until authorized — but once authorized, arbitrary shell, no further restriction | nothing, without an explicit shadowenv trust |
nothing, without an explicit mise trust |
nothing until authorized — same all-or-nothing model as autoenv | whatever the file contains — no different from running any other script |
| Parent directories merge automatically, child overrides parent | ✅ | only via an explicit source_up call in every child .envrc |
✅ | ❌ — needs an explicit .shadowenv.d/parent symlink in every directory |
✅ | ❌ — needs an explicit autoenv_source_parent call in every file |
❌ |
| Zero configuration files | ✅ | ❌ (.envrc per directory) |
✅ | ❌ (.shadowenv.d/) |
❌ (mise.toml) |
❌ (.autoenv.zsh) |
n/a |
| Runtime | single Rust binary | Go binary | Bash script | Rust binary | Rust binary (also a version manager + task runner) | Zsh script | — |
The short version: direnv is powerful and general (it can run arbitrary shell, not just .env files) but that generality is exactly why it needs an explicit .envrc and a trust step per directory — friction easyenv is designed to have none of. autoenv gets the "load on cd in" half right, including automatic parent/child merging, but doesn't unload without extra setup, so variables from one project bleed into the next. shadowenv (also Rust, also a diff/reversal design) and mise both require an explicit trust step too, closer in spirit to direnv here than to easyenv; neither shadowenv nor zsh-autoenv merge parent directories automatically the way easyenv/mise/autoenv do. zsh-autoenv fixes plain autoenv's biggest complaint (no unload) but keeps the same authorization-prompt model. easyenv only does the one job — load/unload .env on cd, with nested overrides — and does it with no config and no prompts. "No trust step" is a fair usability win only because it's backed by an actual enforcement mechanism — see Security for what that mechanism is and its honest limits, and Benchmarks for how these tools compare at deep nesting.
Cold-load latency (time from cd to variables being set) as directory nesting gets deeper, against direnv, autoenv, shadowenv (Shopify), mise (jdx), and zsh-autoenv:
easyenv and shadowenv (also Rust, also diff/reversal-based) stay flat at a few milliseconds out to 128 levels of nesting. direnv grows moderately. autoenv, mise, and zsh-autoenv all grow sharply with depth — mise takes over 2 seconds at 128 levels, autoenv ~1.4–2 seconds, zsh-autoenv ~0.8 seconds. Methodology, caveats (including two tools that need extra per-directory setup just to make nesting work at all), and how to reproduce it: Benchmarks.
There's no daemon. A shell hook (eval "$(easyenv hook bash)" in your rc file) runs on every prompt and calls the easyenv binary, which discovers every .env from your current directory up to the filesystem root, merges them with child-overrides-parent precedence, diffs the result against what it previously set, and prints the minimal export/unset statements for your shell to eval. A cheap signature (directory + each .env's mtime/size) lets it skip all of that instantly when nothing has changed, which is what keeps "run on every prompt" from being noticeable.
Full design write-up: How it works.
Early. Bash and zsh are supported; fish and PowerShell are on the roadmap. Releases are cross-compiled and published automatically (see Release process below); package manager distribution (Homebrew, Scoop/winget) is not set up yet. See PLAN.md for the full roadmap.
$ cargo test # unit tests + end-to-end shell integration tests (bash & zsh)
$ cargo clippy --all-targets -- -D warnings
$ cargo fmtThe shell integration tests in tests/shell_integration.rs actually launch interactive bash/zsh with the real hook installed and drive them through scripted cd/edit sequences — they're the same tests that run in CI.
This repo follows Conventional Commits (feat: ..., fix: ..., docs: ..., etc.), enforced on every pull request by the commitlint CI check. To get the same check locally before you commit:
$ git config core.hooksPath .githooksThe site at chrisbcole.me/easyenv is built from docs/ with MkDocs Material and deployed automatically on push to main. To preview locally:
$ pip install -r requirements-docs.txt
$ mkdocs serveReleases are fully automated by release-please (.github/workflows/release-please.yml) — no manual tagging. It watches Conventional Commits on main and keeps an up-to-date "release PR" with the next version bump and changelog; merging that PR is what actually cuts the release: it tags, publishes the GitHub Release, and triggers cross-compiled builds for Linux (x86_64/aarch64, gnu/musl), macOS (Intel/Apple Silicon), and Windows (x86_64), uploaded as checksummed archives (taiki-e/upload-rust-binary-action). To re-upload binaries for an existing tag without cutting a new release, run the workflow manually (workflow_dispatch) with that tag.
