Why .env instead of direnv for environment variables? #9790
-
SummaryHi, I'd like to understand why Turborepo docs/team suggest using .env instead of direnv. My team uses direnv but would like to use Turborepo and it's suggested best practices (using .env). I'd like to explain why we prefer direnv over .env so that maybe someone can convince me otherwise :) Appreciate any advice experience Turborepo team or the community may have. My team has chosen direnv over .env files because:
The one downside to direnv is that the mechanism to load the .envrc files is in your .zshrc file so that it's not triggered when Turborepo or a script is running. For example, in order to run a deploy.sh we have to: ...
cd packages/app
eval "$(direnv export bash)"
pnpm run deploy
...which is not ideal but this work around has been fine for now. This does prevent us from running commands like Can someone explain their team's process for using .env files that provides as good of DX as direnv? What am I missing? If we were to convert from direnv to .env, we'd need to:
If we were to stick with direnv, how could we still using Turborepo? Can turborepo run Additional informationNo response ExampleNo response |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
|
Beta Was this translation helpful? Give feedback.
.envis command and what people ask about most frequently, so we wrote it down. We don't have an opinion about how you load your local environment variables. Sounds like you have a solution you like and can use!