Skip to content

[BUG] Claude loads my projects .env into its bash environment (!) #401

@rasmuscnielsen

Description

@rasmuscnielsen

Environment

  • Platform (select one):
    • Anthropic API
    • AWS Bedrock
    • Google Vertex AI
    • Other:
  • Claude CLI version: 0.2.35 (Claude Code)
  • Operating System: macOS 15.3.1
  • Terminal: Warp

Bug Description

For the life of me I couldn't figure out why Claude running my Laravel test suite was dropping my local development database every time. During testing, it should rather be using the test environment database for running migrations.

Then after a lot of digging I realized asking Claude to dump its env, it had loaded my projects .env file into its bash env. This causes Laravel to completely ignore whatever I have written in my .env file or any phpunit.xml.

Is it just me or does this seem like a massive issue? Big fan of Claude here and been using the CLI a ton. But I was under the impression that it was quite transparent in what It was doing, but somehow loading my .env wasn't on the list of things I was expecting 🤔

Steps to Reproduce

  1. Create an empty folder and create a .env file with the contents 'MY_SECRET_ENV=test'
  2. Open terminal, navigate to the folder and run claude
  3. Ask Claude to run env. Now you should see 'MY_SECRET_ENV=test ' listed in the output. This will not happen when you just type env in your own bash terminal.

Expected Behavior

Claude should not load my projects .env in its bash environment

Actual Behavior

See above.

Metadata

Metadata

Assignees

Labels

oncallquestionIssue is asking a question about how Claude Code works, or similar

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions