drizzle-kit studio reading .env file

Heya, I just wondered if it's drizzle-kit that automatically reads the .env file? Is it possible to disable that? I'm reading my env files in via nextjs's @next/env library so I can make use of .local etc. But when drizzle-kit reads in the normal .env file next-env can't override the already read env vars with the .env.local since it thinks the already read vars are system wide env variables which always have the highest priority.. Any Idea how to solve this? Just a flag or something that disables automatically reading .env files would be perfect..
3 Replies
Blume
BlumeOP2w ago
bump
ayyjohn
ayyjohn2w ago
As far as I know, yes, drizzle-kit automatically uses .env and won't pick up other options. https://github.com/t3-oss/t3-env/issues/180#issuecomment-2217266081 I'm not sure exactly what you're trying to accomplish but you may be able to use what someone did at the bottom of that thread https://github.com/t3-oss/t3-env/issues/180#issuecomment-2327841601 to get around it? or maybe use multiple drizzle-config files and specify which one you want to use depending on which command you're executing via whichever package manager
GitHub
Can't use env in drizzle.config.ts file · Issue #180 · t3-oss/t3-env
I'm working on a simple app to try something where I got drizzle and drizzle-kit installed, it's a next-js v14.x with @t3-oss/env-nextjs v0.8.0. I'm trying to run drizzle-kit generate:p...
Blume
BlumeOP6d ago
Thank you! I'll have a look :) We solved it for now by omitting the problematic env vars in our normal .env.. Hmm the linked issue comment unfortunately won't solve our problem.. loadEnvConfig from next/env still will treat every already existing env var as highest priority and not override it.. I fear the only viable solution would be to prevent drizzle from loading the .env by itself and give full controll to the developers.. But sounds like thats not a priority for them

Did you find this page helpful?