jetify-com / devbox

Instant, easy, and predictable development environments
https://www.jetify.com/devbox/
Apache License 2.0
7.84k stars 188 forks source link

Support multiple .env files with direnv #2180

Open ahochsteger opened 3 days ago

ahochsteger commented 3 days ago

What problem are you trying to solve?

Many development setups I work with use more than one .env file - most commonly one that contains values that are shared among all developers and thus committed into GIT and one that is private and thus excluded from .gitignore. devbox currently does not support such kind of setups, since devbox generate direnv does not allow to pass multiple env files.

What solution would you like?

direnv already allows to do that using by just listing multiple .env files in .envrc like this:

dotenv_if_exists .env.shared
dotenv_if_exists .env

If the command devbox generate direnv would allow to specify --env-file multiple times and put them in the given order into the generated .envrc file and also output them in the given order when the option --print-envrc is used, then everything would just work as expected.

Alternatives you've considered

Passing multiple --env-file arguments has been tried but that did not work as it just uses the last given one. A workaround is to manually write the .envrc file but that means a lot of extra manual work in every affected git repository and the risk to lose the good integration by not conforming to the recommended direnv setup anymore.