📂
Languages & Build

direnv

Auto-load project env vars when you cd into a folder

🐧 Linux🍎 Mac🪟 Windows
Reviewed: Tested on: Kubernetes 1.29 · Terraform 1.8 · Ubuntu 22.04

What is this?

direnv loads environment variables automatically when you enter a project directory.

📁

Config files for direnv

Where to create or edit the main configuration — paths below match the setup steps.

  • .envrc

    Location: Project directory (auto-loaded on cd)

    Per-project environment variables

📥

Step 01

Install direnv

(01)Install direnv

Linux
1sudo apt-get install -y direnv
2echo 'eval "$(direnv hook bash)"' >> ~/.bashrc
⚙️

Step 02

Configure direnv

(01)Configure direnv

Linux
1echo 'export API_KEY=dev' > .envrc
2direnv allow

Step 03

Verify

(01)Verify installation

Linux
1direnv version