Skip to main content

Documentation 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.

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 an .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

1
Install direnv
2
Follow the official installation instructions to install direnv from your system’s package manager.
3
Add the direnv hook to your shell
4
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:
#!/usr/bin/env bash

eval "$(devenv direnvrc)"

# You can pass flags to the devenv command
# For example: use devenv --impure --option services.postgres.enable:bool true
use devenv
From v1.4 onward, 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: error ~/myproject/.envrc is blocked. Run `direnv allow` to approve its content
Run 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:
$ cd /home/user/myproject/
direnv: loading ~/myproject/.envrc
Building shell ...
Entering shell ...

(devenv) $

Passing flags to devenv

You can pass command-line options directly to devenv by adding them after use devenv in your .envrc:
# Example: override configuration options
use devenv --option services.postgres.enable:bool true

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:
$ echo ".direnv" >> .gitignore

Manually managing updates to direnvrc

The devenv 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:
https://raw.githubusercontent.com/cachix/devenv/VERSION/devenv/direnvrc
Replace VERSION with a git tag or branch name. For example, for version 1.9.2:
https://raw.githubusercontent.com/cachix/devenv/v1.9.2/devenv/direnvrc
1
Compute the SHA-256 hash
2
$ direnv fetchurl "https://raw.githubusercontent.com/cachix/devenv/VERSION/devenv/direnvrc"
3
Found hash: <HASH>
4
Update your .envrc
5
source_url "https://raw.githubusercontent.com/cachix/devenv/VERSION/devenv/direnvrc" "<HASH>"

use devenv

Build docs developers (and LLMs) love