direnv is a free extension for your shell that switches environment variables automatically as you move between folders. You put export lines in a file called .envrc inside a project, approve it once with direnv allow, and from then on every time you cd into that folder its variables load, and when you leave they are removed again. Setup takes two minutes: install it and add one hook line to your shell's config file.
It earns its place because projects need different settings: API keys for testing, a database address, a PATH that points at the project's own tools, a Python virtual environment or a Node version. Without direnv those end up in your global profile or get typed by hand. It works with bash, zsh, fish, tcsh, elvish, PowerShell, murex and Nushell, can also read a plain .env file if you switch that on, and has a standard library of helpers such as layout python and use nix. As a safety step it refuses to run a new or changed .envrc until you approve it.
direnv is MIT licensed and written in Go, started in 2011 and maintained by zimbatm and contributors. It has about 15,500 stars and close to 300 contributors. Version 2.38.2 came out on 10 October 2026.
- Repository: github.com/direnv/direnv
- Licence: MIT (MIT License)
- Language: Go. Stars: 15.6K. Forks: 894. Last push: Nov 30, 2026.
- Scan: safe, Dec 4, 2026, commit 3d0b4ae
Who it is for
Developers who juggle several projects with different keys, tool versions or settings, teams that share a project's environment setup, and Nix and Python users who want environments to switch on by themselves. You need to be comfortable editing your shell's config file; it is built for macOS, Linux and other Unix-like systems.
Getting started
1. macOS or Linux with Homebrew (or your distribution's package, such as sudo apt install direnv)
brew install direnv2. Hook it into zsh (for bash, use direnv hook bash in ~/.bashrc), then open a new terminal
echo 'eval "$(direnv hook zsh)"' >> ~/.zshrc3. Make a project folder with an .envrc file
mkdir ~/my-project && cd ~/my-project
echo 'export FOO=foo' > .envrc4. Approve the file so direnv will load it
direnv allow .5. Check it loaded, then leave and watch it unload
echo $FOO
cd ..The hook line runs direnv before each prompt; take it out of your shell config to switch direnv off. An .envrc file is bash code, so read one from someone else's project before you run direnv allow on it; that approval step is the main protection. The project's curl install script downloads the latest release into a folder on your PATH and prints the hook line for you to add; it does not edit your profile or use sudo, but it does not check a checksum either. Our scan covers the source code, not the prebuilt binaries or distribution packages.
Safety scan
We cloned direnv/direnv at commit 3d0b4ae on Dec 4, 2026 and ran the checks described on the GitHub Tools page: credential patterns, decode-and-execute code, install-time scripts, committed binaries, risky CI workflows, every host the code talks to, known vulnerabilities in pinned dependencies, and project hygiene. A person read every hit. This is what we found.
- 0 secret hits and no committed binaries across 180 files and about 12,700 lines, mostly Go and shell.
- 0 pattern hits. There are no install hooks or build scripts beyond the Makefile used to build it from source.
- install.sh asks the GitHub API for the latest release, downloads the binary for your system over HTTPS into a folder on your PATH (or the bin_path you set), makes it executable and prints the hook line for you to add. It uses no sudo and does not edit your shell profile, but it does not verify a checksum.
- 0 advisories across its 5 pinned dependencies: 4 Go modules in go.mod and 1 Python package used only by a test scenario.
- direnv makes no network connections and has no telemetry; the web addresses in the repository are links in its docs and the installer's GitHub download. 4 workflows, none on pull_request_target. One runs only for Dependabot's pull requests and pushes a checksum update back to Dependabot's branch. Third-party actions are named by version tag, not pinned to a commit. Dependabot and CodeQL are on; no security policy; its OpenSSF Scorecard is 3.8 out of 10.
What the scanner counted
| Check | Result |
|---|---|
| Secrets | None found. |
| Suspicious code | None found. |
| Install-time code | 1 installer script (one edits your shell profile) |
| Committed binaries | None. |
| CI workflows | 4 workflows. None use pull_request_target. 3 of 3 third-party actions pinned to a tag rather than a commit. |
| Network hosts | 12 distinct hosts referenced from source; most often github.com, api.github.com, direnv.net, learn.microsoft.com. No URLs to bare IP addresses. |
| Known vulnerabilities | 0 advisories across 5 pinned packages: 0 critical, 0 high, 0 moderate, 0 low. go.mod: 4 packages, 0 advisories; test/scenarios/uv-layout/uv.lock: 1 packages, 0 advisories. |
| Project hygiene | Has automated dependency updates, CodeQL, licence file, contributing guide. Missing security policy. |
| OpenSSF Scorecard | 3.8 out of 10, as of Nov 30, 2026. |
The raw findings
Every hit the scanner wrote out, with a link to the exact line at the scanned commit. Secrets candidates are redacted.
Installer scripts (1)
- install.sh, 126 lines, edits your shell profile; talks to api.github.com, direnv.net, github.com
By the numbers
| Stars | 15.6K |
|---|---|
| Forks | 894 |
| Contributors | 292 |
| Commits | 1,486 |
| Open issues | 304 |
| Open pull requests | 56 |
| Releases | 66 |
| Latest release | v2.38.2 |
| Licence | MIT |
| Main language | Go |
| Project age | 15 years |
| Last push | Nov 30, 2026 |
| Tracked files | 180 |
| Lines of code | 12.7K |
| Checkout size | 396 KB |
Lines by language: Go 6,450, Shell 2,897, Markdown 2,693, PowerShell 377, YAML 281, TOML 28.
Questions
Is direnv free?
Yes. It is free and open source under the MIT licence, with no account and no paid version.
direnv or a .env file?
A .env file only helps apps that read it themselves. direnv loads the variables into your shell, so every command you run in that folder sees them, and it can read .env files too if you turn that on.
Is it safe to keep secrets in .envrc?
It keeps them out of your global profile, but the file sits in your project folder as plain text, so add .envrc to .gitignore and never commit it.
Does direnv work on Windows?
It is built for Unix-like systems such as macOS and Linux, and the README lists that as a requirement. On Windows people usually run it inside WSL.
How do I uninstall direnv?
Remove the eval line from your shell config, then uninstall it with your package manager, for example brew uninstall direnv. Your .envrc files stay in place and simply stop loading.
This post is part of GitHub Tools, where every repository is cloned and scanned before it is written up. The scan is a snapshot of one commit on one day; the repository has moved on since, so check it before you install.
