You can configure devenv to seamlessly switch development environments when navigating between project directories. This feature relies on a separate tool called direnv (not to be confused with devenv), which hooks into your shell and evaluates anDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/cachix/devenv/llms.txt
Use this file to discover all available pages before exploring further.
.envrc file each time you enter or leave a directory.
Native auto-activation is the recommended approach for most workflows. As of devenv 2.0,
devenv shell supports native shell reloading, and devenv hook provides automatic activation when switching directories with no external dependencies. direnv is still useful if you prefer in-place environment modification without spawning a subshell. See the auto-activation guide for setup instructions.Installing direnv
Follow the official installation instructions to install direnv from your system’s package manager.
Hook direnv into your shell by following the direnv hook guide. This adds a small snippet to your shell configuration file (e.g.,
~/.bashrc, ~/.zshrc).Configure shell activation
Create an.envrc file in your project directory:
- v1.4+
- v1.3 and older
eval "$(devenv direnvrc)" fetches the latest compatible integration script automatically — no manual hash pinning required.devenv init does not create a .envrc file by default. As of devenv 2.2, you can run devenv init --include-envrc to generate one automatically.Approving and loading the shell
Once the.envrc file is in place, direnv will show a warning:
direnv allow to approve the file. This is a security measure to ensure you’ve reviewed the content before allowing it to modify your shell environment.
After approval, direnv automatically loads and unloads the devenv environment as you navigate in and out of the project directory:
Passing flags to devenv
You can pass command-line options directly to devenv by adding them afteruse devenv in your .envrc:
Customizing PS1
If you’d like your shell prompt to reflect the active direnv environment, we recommend installing Starship, which integrates with direnv out of the box.Ignoring the .direnv directory
Running devenv init adds .direnv to your .gitignore automatically. To add it manually:
Manually managing updates to direnvrc
Thedevenv direnvrc integration script (also called the direnvrc) is occasionally updated. When using the v1.4+ method, devenv always uses the latest compatible version automatically.
If you need to pin to a specific version — for example, to audit the script or control when updates apply — you can source it directly from the repository:
VERSION with a git tag or branch name. For example, for version 1.9.2:
