Prisma loads .env, processes differently from RWJS

In short, when running yarn rw dev, Prisma reads .env before RWJS ever does. And when Prisma reads .env, it handles multiline vars correctly. When RWJS reads .env, it doesn’t (appear to) handle multiline vars.
Because Prisma loading .env causes all vars in .env to be loaded into the environment(whether related to Prisma or not), the later read of .env by RWJS doesn’t really do anything (dotenv doesn’t normally overwrite existing vars). But, if for some reason Prisma doesn’t read .env, then RWJS will, but won’t bring in the whole of a multiline env var.
This subtle interaction between Prisma and RWJS both processing .env leads to a less than great DX (and a multiple day debugging exercise to find out what was going on).
Question: Can/should RWJS use a different environment file for Prisma than for RWJS itself?
Related question: Is there a way to specify dotenv/dotenv-defaults options for RWJS?

This almost sounds like it could have been filed as an issue on our GitHub issue tracker. Definitely doesn’t sound great :confused: Sorry you had to struggle with it for so long. I’ve pinged the team about this one. Hopefully someone who knows this stuff better than me comes around to help

+1 for writing the up as an issue so we can collect a few reproducible examples and cases.

Then once we understand and see first hand, we can connect with Prisma and see what’s the next best course of action.

@joconor Might you be able to write up and even give some example .env files with expected and unexpected behavior?

Github issue created Prisma loads .env, processes differently from RWJS · Issue #5657 · redwoodjs/redwood · GitHub

2 Likes