LinuxmacOS

Where Does direnv Store Config and Project Files?

direnv reads direnv.toml in ~/.config/direnv on Unix, with per project .envrc files doing the real work beside it.

Last updated

direnv splits config two ways. Global behavior lives in direnv.toml under ~/.config/direnv. Project behavior lives in .envrc files inside each repo. The global file tunes warnings and whitelists, the project files export the actual variables.

Shell hooks tie it together through your rc file. Extensions drop into direnvrc or the lib folder beside the toml. Per project layouts cache under .direnv in the project itself, which belongs in gitignore next to the allow record.

Where direnv stores this, by platform

Linux
~/.config/direnv/direnv.toml

Global toml plus direnvrc extensions and lib scripts. Project .envrc files carry the real config. Respects $XDG_CONFIG_HOME and $DIRENV_CONFIG.

macOS
~/.config/direnv/direnv.toml

Same layout as Linux through Homebrew or Nix installs. Hook with eval $(direnv hook zsh) in ~/.zshrc. Layout caches land in per project .direnv folders.

Frequently asked questions

How do I set up direnv for a project?

Create a file named .envrc in the project root with export lines or layout directives, then run direnv allow. The shell loads it on entry and unloads on exit. Commit a .envrc.sample and ignore the live file when secrets are involved.

direnv stopped loading after I moved the folder. Why?

Run direnv status to see loaded files, then direnv deny on the stale path. Moving folders invalidates the allow record by design, since approval binds to the exact path. Re allow after every move.

Notice an outdated path? Let us know.