prisma generate tries to fetch engine checksum files from mirror even if custom engine locations are provided in an .env file
See original GitHub issueBug description
The docs mention that the PRISMA_*_ENGINE_BINARY
variables can be added via an env file - https://www.prisma.io/docs/concepts/components/prisma-engines#a-the-env-file
When running prisma generate
it seems that prisma tries to fetch binaries before loading any environment variables from an .env file (.env or prisma/.env). If you’re behind a firewall that doesn’t allow access to https://binaries.prisma.sh then the generation fails right at that step even if there are custom locations for binaries in the env variables in an .env file.
If you load the env variables into the shell environment before running prisma generate
that will preempt the fetching of binaries from a mirror however.
For our use case, it’s often more convenient (and sometimes really the only option) to provide shared non-secret env variables via a .env file checked into source control rather than define them on the CI box itself. So if prisma CLI could load env variables before attempting the download of binaries that would solve this issue. I’m willing to contribute if someone could point me to where this functionality lives!
How to reproduce
- Block access to https://binaries.prisma.sh (make sure there’s no cache in
~/.cache/prisma
or the corresponding cache location for your os) - Perform a fresh
npm install
ofprisma
and@prisma/client
- Run
npx prisma generate
should fail with a network error trying to access https://binaries.prisma.sh
Expected behavior
prisma generate
(or any other prisma commands for that matter) should read the engine binary location from the env variables in the .env file instead of trying to download them from the mirror.
Prisma information
N/A
Environment & setup
- OS: Mac OS
- Database: N/A
- Node.js version: 16.14.0
Prisma Version
prisma : 3.10.0
@prisma/client : 3.10.0
Current platform : darwin-arm64
Query Engine (Node-API) : libquery-engine 73e60b76d394f8d37d8ebd1f8918c79029f0db86 (at node_modules/@prisma/engines/libquery_engine-darwin-arm64.dylib.node)
Migration Engine : migration-engine-cli 73e60b76d394f8d37d8ebd1f8918c79029f0db86 (at node_modules/@prisma/engines/migration-engine-darwin-arm64)
Introspection Engine : introspection-core 73e60b76d394f8d37d8ebd1f8918c79029f0db86 (at node_modules/@prisma/engines/introspection-engine-darwin-arm64)
Format Binary : prisma-fmt 73e60b76d394f8d37d8ebd1f8918c79029f0db86 (at node_modules/@prisma/engines/prisma-fmt-darwin-arm64)
Default Engines Hash : 73e60b76d394f8d37d8ebd1f8918c79029f0db86
Studio : 0.458.0
Issue Analytics
- State:
- Created a year ago
- Reactions:2
- Comments:5 (2 by maintainers)
Top GitHub Comments
Ok, so this is indeed trying to fetch the checksum files (see the
.sha256
at the end of the filename) of the engine archives - which is a known problem and we already have an issue for. I will keep this open anyway, just to be sure.@juzerzarif
I think I know where the logic to control the download is
see https://github.com/prisma/prisma/blob/2134569191e2d67c1788488ede0f4e54460d4e11/packages/cli/src/bin.ts#L137-L149
and https://github.com/prisma/prisma/blob/2134569191e2d67c1788488ede0f4e54460d4e11/packages/cli/src/CLI.ts#L65-L69
As long as the specified command is removed from the array, the download can be disabled. I think it can be temporarily processed through the patch mechanism of the package manager, such as pnpm patch or patch-package