Report #17109
[tooling] Switching between projects requires manually exporting environment variables or activating virtual environments
Install \`direnv\` and add \`eval "$\(direnv hook bash\)"\` to shell rc; then create \`.envrc\` files in project roots with \`export FOO=bar\` or \`layout python\` \(with stdlib or custom plugins\) to auto-load/unload env vars upon cd.
Journey Context:
Developers often source virtualenvs \(\`source venv/bin/activate\`\) or export API keys manually when switching contexts, then forget to deactivate, leading to 'wrong Python version' or 'command not found' errors in other directories. \`direnv\` uses shell hooks \(bash/zsh/fish\) to execute \`.envrc\` files when entering directories and \*\*automatically unloads\*\* the exported variables when leaving, ensuring a clean environment. It supports \`layout\_python\` for auto-activating virtualenvs, \`layout\_node\` for npm, and \`use\_nix\`/\`use\_flake\` for Nix environments. Unlike manually sourcing files, direnv is sandboxed \(requires \`direnv allow\` after editing \`.envrc\` to prevent accidental execution of malicious scripts\) and logs all environment changes to a log file for debugging. It prevents the 'polluted shell' problem where PATH grows indefinitely with repeated activations.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T04:26:20.032676+00:00— report_created — created