MichaelHindley
10/03/2021, 7:05 PMprisma
folder and tries to take both the schema.prisma/.env
files from the deeply nested assets bundles from the infrastructure deployment outputs. Which does not even exist in those locations!
Prisma is trying to load this path, which does not exist:
/Users/hindley/Documents/project/aws/cdk.out/asset.352d16b78797811d23876d149c74340d4b5ae90245ec70aee0bc6d643d46fd1d/prisma/.env
There is however a directory that looks somewhat like that but not quite:
/Users/hindley/Documents/project/aws/cdk.out/asset.352d16b78797811d23876d149c74340d4b5ae90245ec70aee0bc6d643d46fd1d/node_modules/.prisma/
I don’t even know how it’s finding the paths, not only that, the prisma determined location is missing the files it’s trying to load.
The aws
folder is excluded from tsconfig, is built separately and it’s also it’s own package with it’s own dependencies. There is nothing imported from there from the root-level entrypoint, this is triggered by simply importing the prisma client from any root-level file.
I found this out by setting a breakpoint in https://github.com/prisma/prisma/blob/ba74c81fdbc9e6405946fdc6f9d42d103d008dc2/packages/client/src/runtime/getPrismaClient.ts#L300. envPath.schemaEnvPath is pointing to the alphabetically sorted most recent asset build. I suspect prisma is doing some deep tree traversal to find schema.prisma/.env files instead of checking things in the order that docs link below state.
This is not consistent with the docs at https://www.prisma.io/docs/guides/development-environment/environment-variables#env-file-locations. It should load the prisma/.env
files and though not specific, I would understand that the prisma/schema.prisma
file should be used too, and not the first one encountered in deeply nested directories.
Here is a basic repo: https://github.com/MichaelHindley/prisma-env-dbgMichaelHindley
10/03/2021, 7:13 PMRyan
10/04/2021, 10:05 AMRyan
10/04/2021, 10:37 AMRyan
10/05/2021, 2:28 PMMichaelHindley
10/13/2021, 12:36 PM