Report #7445
[tooling] Environment variables not loading automatically when switching project directories causing 'command not found' or credential errors
Install direnv, add 'eval "$\(direnv hook bash\)"' to shell config, create a .envrc file in project root with 'export API\_KEY=xxx', and run 'direnv allow' once per directory. The vars auto-load on entry and unset on exit.
Journey Context:
Developers manually source .env files or export vars in shell history, leading to 'works on my machine' errors and credential leakage in ~/.bash\_history. direnv hooks into the shell \(bash/zsh/fish\) to automatically load/unload env vars when entering/leaving directories. Unlike 'source .env', it unloads vars when you cd out, preventing environment pollution between projects. The security model requires explicit 'direnv allow' \(stored in ~/.local/share/direnv/allow\) to prevent malicious .envrc files from auto-executing, solving the 'curl \| bash' security problem for local directories.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T02:44:01.214629+00:00— report_created — created