question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

prisma generate tries to fetch engine checksum files from mirror even if custom engine locations are provided in an .env file

See original GitHub issue

Bug 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

  1. Block access to https://binaries.prisma.sh (make sure there’s no cache in ~/.cache/prisma or the corresponding cache location for your os)
  2. Perform a fresh npm install of prisma and @prisma/client
  3. 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:open
  • Created a year ago
  • Reactions:2
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
janpiocommented, Apr 8, 2022

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.

0reactions
ityuanycommented, Nov 17, 2022

@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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Environment variables - Prisma
The Prisma CLI looks for .env files, in order, in the following locations: ... We suggest to move the contents of prisma/.env to...
Read more >
A curated list of awesome Go frameworks, libraries and ...
support JSON, YAML, TOML, INI, HCL. multi file load, data override merge. harvester - Harvester, a easy to use static and dynamic configuration...
Read more >
.npmrc | pnpm
pnpm gets its configuration from the command line, environment variables, and .npmrc files. The pnpm config command can be used to update and...
Read more >
Profile for deps Co. - Linknovate
If you still don't get how DAG pipelines are useful, here is another ... easier in your MSYS2 environment, consider writing a custom...
Read more >
W3layouts cms exploit - Weebly
remove the .editorig .env .env file vars nto defined in the .env tutorial .ep ... I get money from stack overflow can I...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found