Disable forced `.env` loading
Is your feature request related to a problem? Please describe.
I have a mono-repo with env var loading handled by direnv. In particular it loads env vars from files in this order:
.env then .env.local. Now when I run:
uv --directory=python/example-buyers run -- adk run src/example_buyers/adk/a2a_example
ADK re-loads .env file automatically, negating any overrides in .env.local
I understand this is a convenience feature, but it'd be great if there was a way to disable this behavior.
Describe the solution you'd like
A flag I can pass to adk run like --no-dotenv or similar, to disable this automatic behavior.
Describe alternatives you've considered
For now, I've renamed by env files to .env.dev and .env.local.
We have the same issue in a monorepo.
Not a solution but a temporary workaround:
.env in the agents folder (the var name doesn't matter)
# This file prevents the adk from traversing up the directory tree searching for .env files
PREVENT_PARENT_ENV_LOAD=true
We committed this file to our repo.
Thanks @bastiandg, that's a neat workaround 👍
@speedstorm1 - I can work on this
Hi @bastiandg and @matiasedgeandnode ,
Thanks for bringing this up. Now, as part of https://github.com/google/adk-python/commit/15afbcd1587d4102a4dc5c07c0c493917df9d6ea, you may set the environment variable ADK_DISABLE_LOAD_DOTENV=true to skip the automatic .env loading.
Thanks for fixing this @speedstorm1 👍