aider icon indicating copy to clipboard operation
aider copied to clipboard

Loading env files no longer clobbers the loaded environment

Open spott opened this issue 8 months ago • 0 comments

If the user has an env variable loaded, that variable is no longer clobbered by a .env file referencing the same variable.

So if your env has "ANTHROPIC_API_KEY", and you have an env file with "ANTHROPIC_API_KEY", you will use the value from your environment, rather than your env file. This sets up the priority:

$HOME/.env $GIT_ROOT/.env $PWD/.env ${--env-file}

Part of the reason I think this is the correct way to do this is that there are a couple of secret management tools that will parse an env file with secret references into the environment with secrets (so an env file with USERNAME="op://vault/secret name/username" gets instantiated in the environment as USERNAME=<my secret username>). This is how I discovered this behavior.

spott avatar Apr 25 '25 17:04 spott