Unexpected binaryTargets environment variables usage
See original GitHub issueBug description
In version 2.22 and below, I was able to use an environment variable to set binaryTargets
. This was the generator
part in my schema:
generator client {
provider = "prisma-client-js"
binaryTargets = [env("PRISMA_BINARY_TARGET")]
}
I could run something like this to set this environment variable:
$ PRISMA_BINARY_TARGET='native' yarn prisma generate
However, it does not work like this anymore in v2.26. If I upgrade Prisma to 2.26 and try running the same command, I’d get an error like this ( with DEBUG="prisma*"
turned on):
How to reproduce
- Create a new schema
- Use an environment variable for
binaryTargets
- Set the environment variable when running relevant commands like
prisma generate
Expected behavior
I was expecting v2.26 to work the same way as v2.22 and before:
$ PRISMA_BINARY_TARGET='native' yarn prisma generate
Would be nice to also have this documented somewhere as well ( Maybe it’s out there but I missed it 😃 ? )
Alternative
Given the following setting:
generator client {
provider = "prisma-client-js"
binaryTargets = env("PRISMA_BINARY_TARGET") // Notice env is now the `binaryTargets` array
}
Maybe the targets can be passed in with a ,
separator? For example:
$ PRISMA_BINARY_TARGET='native,darwin' yarn prisma generate
Current workaround
After digging around a bit in this file, I found that it was expecting an array in JSON string instead of a string. That means I could do something like this:
$ PRISMA_BINARY_TARGET='["native"]' yarn prisma generate
Prisma information
N/A
Environment & setup
- OS: MacOS
- Database: MySQL
- Node.js version: 12.13.1
Prisma Version
prisma : 2.26.0
@prisma/client : 2.26.0
Current platform : darwin
Query Engine : query-engine 9b816b3aa13cc270074f172f30d6eda8a8ce867d (at node_modules/@prisma/engines/query-engine-darwin)
Migration Engine : migration-engine-cli 9b816b3aa13cc270074f172f30d6eda8a8ce867d (at node_modules/@prisma/engines/migration-engine-darwin)
Introspection Engine : introspection-core 9b816b3aa13cc270074f172f30d6eda8a8ce867d (at node_modules/@prisma/engines/introspection-engine-darwin)
Format Binary : prisma-fmt 9b816b3aa13cc270074f172f30d6eda8a8ce867d (at node_modules/@prisma/engines/prisma-fmt-darwin)
Default Engines Hash : 9b816b3aa13cc270074f172f30d6eda8a8ce867d
Studio : 0.408.0
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:6 (4 by maintainers)
Top GitHub Comments
Internal Note: We need to confirm the described behavior in 2.22.0, reproduce the failure in recent versions and then understand how and why this changed - and then decide if this is something we can or want to undo, and how to properly document this.
Sorry. The problem is not relevant. I fixed this by copying the .env file to inside docker container.