Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misleading error message when the query engine is not found #15292

Closed
aqrln opened this issue Sep 13, 2022 · 4 comments · Fixed by #19330
Closed

Misleading error message when the query engine is not found #15292

aqrln opened this issue Sep 13, 2022 · 4 comments · Fixed by #19330
Labels
bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. kind/bug A reported bug. team/client Issue for team Client. tech/typescript Issue for tech TypeScript. topic: engine-not-found topic: error topic: Query engine ... could not be found. Query engine ... for current platform ... could not be found.
Milestone

Comments

@aqrln
Copy link
Member

aqrln commented Sep 13, 2022

Bug description

I generated the client in a aarch64 VM and I wanted to check something with the same project in a x86-64 VM. However, I forgot to re-generate the client. I got the following error:

/home/aqrln/repro/node_modules/.prisma/client/runtime/index.js:29915
      throw new PrismaClientInitializationError(message, this.client._clientVersion);
            ^

PrismaClientInitializationError:
Invalid `prisma.user.findMany()` invocation:


Query engine library for current platform "debian-openssl-1.1.x" could not be found.
You incorrectly pinned it to debian-openssl-1.1.x

This probably happens, because you built Prisma Client on a different platform.
(Prisma Client looked in "/home/aqrln/repro/node_modules/.prisma/client/runtime/libquery_engine-debian-openssl-1.1.x.so.node")

Searched Locations:

  /home/aqrln/repro/node_modules/.prisma/client
  /home/aqrln/repro/node_modules/.prisma/client
  /home/aqrln/repro/node_modules/.prisma/client
  /home/aqrln/repro/node_modules/.prisma/client
  /home/aqrln/repro/prisma
  /tmp/prisma-engines
  /home/aqrln/repro/node_modules/.prisma/client


To solve this problem, add the platform "debian-openssl-1.1.x" to the "binaryTargets" attribute in the "generator" block in the "schema.prisma" file:
generator client {
  provider      = "prisma-client-js"
  binaryTargets = ["native"]
}

Then run "prisma generate" for your changes to take effect.

This error is mostly correct except one line that is very wrong and misleading:

You incorrectly pinned it to debian-openssl-1.1.x
  1. I didn't "pin" it to any platform — there's no binaryTargets in my schema.
  2. If I did, debian-openssl-1.1.x would have been exactly the right platform.

How to reproduce

Option 1

  1. Generate the client on one platform
  2. Copy the project to another machine/VM with a different platform
  3. Try to use the client

Option 2

  1. Generate the client on Linux
  2. Run a Node.js binary for a different CPU architecture via QEMU usermode emulation

I didn't check, but a variant of option 2 on macOS with Rosetta is probably also possible.

Expected behavior

No "You incorrectly pinned it to debian-openssl-1.1.x" line in the error message

Prisma information

generator client {
  provider = "prisma-client-js"
  output = "../node_modules/.prisma/client"
}

datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}

model User {
  id    Int    @id
  login String @unique
}
import { PrismaClient } from '@prisma/client'

async function main() {
  const client = new PrismaClient()

  const results = await client.user.findMany()
  console.log(results)
}

void main()

Environment & setup

  • OS:
    • Linux debian 5.10.0-18-arm64 #1 SMP Debian 5.10.140-1 (2022-09-02) aarch64 GNU/Linux
    • Linux debian86 5.10.0-18-amd64 #1 SMP Debian 5.10.140-1 (2022-09-02) x86_64 GNU/Linux
  • Database: postgres (PostgreSQL) 14.5 (Debian 14.5-1.pgdg110+1)
  • Node.js version: v18.9.0

Prisma Version

prisma                  : 4.3.1
@prisma/client          : 4.3.1
Current platform        : debian-openssl-1.1.x
Query Engine (Node-API) : libquery-engine c875e43600dfe042452e0b868f7a48b817b9640b (at node_modules/@prisma/engines/libquery_engine-debian-openssl-1.1.x.so.node)
Migration Engine        : migration-engine-cli c875e43600dfe042452e0b868f7a48b817b9640b (at node_modules/@prisma/engines/migration-engine-debian-openssl-1.1.x)
Introspection Engine    : introspection-core c875e43600dfe042452e0b868f7a48b817b9640b (at node_modules/@prisma/engines/introspection-engine-debian-openssl-1.1.x)
Format Binary           : prisma-fmt c875e43600dfe042452e0b868f7a48b817b9640b (at node_modules/@prisma/engines/prisma-fmt-debian-openssl-1.1.x)
Format Wasm             : @prisma/prisma-fmt-wasm 4.3.0-32.c875e43600dfe042452e0b868f7a48b817b9640b
Default Engines Hash    : c875e43600dfe042452e0b868f7a48b817b9640b
Studio                  : 0.473.0
@aqrln aqrln added kind/bug A reported bug. bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. process/candidate topic: error tech/typescript Issue for tech TypeScript. team/client Issue for team Client. labels Sep 13, 2022
@janpio
Copy link
Member

janpio commented Sep 13, 2022

(I think there are older issues about this same confusing error message - it is a really dark and ugly corner of the Client logic.)

@bam4564
Copy link

bam4564 commented Mar 12, 2023

Any updates here? Also struggling with this issue.

@janpio
Copy link
Member

janpio commented Mar 14, 2023

Please open a new issue @bam4564 and describe your problem in detail. This issue here is only about the error message (text), not the actual underlying problem of which there can be many, many different ones. Thanks.

@millsp
Copy link
Member

millsp commented May 31, 2023

Hey, we wanted to give you an update about this. We have around 10 issues that we have identified to be in the "engine not found" category. Looking at these, we learned that there are four main categories responsible for these errors:

  • Your client was generated with native (default) on one platform, but used on a different platform at runtime.
  • You pinned binaryTargets incorrectly, and the correct engine was therefore not included at runtime.
  • A bundler/framework changed the Prisma Client but did not copy the necessary engine for the runtime.
  • Deployment/tooling did not copy the engine correctly so the correct engine was not included at runtime.

These cases were previously not detected. On top of that, the error messages were confusing and were neither helpful for you or us. With that, it is likely that many of the cases above overlapped each other. So while we cannot fix a missing engine, we can detect how and why it happened. Thanks to that, we now display more useful errors to help you out of trouble. And in some cases, we will ask some input from you to learn more about your project so we can further improve.

If something is still off for you, feel free to create a new issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. kind/bug A reported bug. team/client Issue for team Client. tech/typescript Issue for tech TypeScript. topic: engine-not-found topic: error topic: Query engine ... could not be found. Query engine ... for current platform ... could not be found.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants