-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Description
Preflight Checklist
- I have searched existing issues and this hasn't been reported yet
- This is a single bug report (please file separate reports for different bugs)
- I am using the latest version of Claude Code
What's Wrong?
When claude code runs things in my project, it automatically includes the .env file in the environment of the command that it runs. This causes the commands to run with a different environment than when I run them myself, it causes my integration tests to run with the wrong environment and wrong backends.
I can't find any documentation about this and claude code doesn't seem to know that it does this:
... Looking at your environment output, I can see that environment variables from the project's .env file are being loaded automatically - likely through your shell configuration (probably via something like direnv or a similar tool, or perhaps a shell hook in your zsh config).
What Should Happen?
I would expect:
- that claude code runs commands with the same environment variables that it is run with (with some changes).
- documentation about this behaviour - which I don't find.
- Claude to know about this behaviour so it can help me with issues caused by it (but claude suggests it's part of my environment)
Error Messages/Logs
Steps to Reproduce
- run claude code, check the env:
!env
- create a .env file with something in it
- check the env in claude again and find it has included the new entry
Claude Model
Opus
Is this a regression?
Yes, this worked in a previous version
Last Working Version
about a month ago
Claude Code Version
2.0.55
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Other
Additional Information
No response