prisma: Query Engine Library Not Found

Bug description

We have recently been seeing query engine library errors on our app hosted on vercel. This has been happening for about a day and suddenly started happening intermittently. This is really weird because it says it wants “rhel-openssl-1.1.x” and that we incorrectly pinned to “rhel-openssl-1.1.x”. We have tried to explicitely add binaryTargets = ["native", "rhel-openssl-1.0.x", "rhel-openssl-1.1.x"], but this causes our build to fail with function size errors. I would appreciate any pointers here.

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

This probably happens, because you built Prisma Client on a different platform.
(Prisma Client looked in "/var/task/node_modules/@prisma/client/ultron/runtime/libquery_engine-rhel-openssl-1.1.x.so.node")

Searched Locations:

  /var/task/node_modules/@prisma/.prisma/client
  /vercel/path0/node_modules/@prisma/client/ultron
  /var/task/node_modules/@prisma/client/ultron
  /var/task/node_modules/@prisma/client/ultron
  /var/task/node_modules/@prisma/client/ultron
  /tmp/prisma-engines
  /var/task/node_modules/@prisma/client/ultron


To solve this problem, add the platform "rhel-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.
Read more about deploying Prisma Client: https://pris.ly/d/client-generator

I see a related issue here: #13266

How to reproduce

It currently seems to cause random requests to error out. I am not able to identify a pattern here.

Expected behavior

I expect the right query engine library to be used.

Prisma information

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

generator client {
  provider        = "prisma-client-js"
  previewFeatures = ["filterJson", "dataProxy"]
  output          = "../../../../node_modules/@prisma/client/ultron"
}

generator dbml {
  provider = "prisma-dbml-generator"
}

Environment & setup

This is currently happening on vercel’s serverless platform which I believe uses AWS.

Prisma Version

prisma                  : 3.11.1
@prisma/client          : 3.11.1
Current platform        : darwin-arm64
Query Engine (Node-API) : libquery-engine 1a2506facaf1a4727b7c26850735e88ec779dee9 (at node_modules/prisma/node_modules/@prisma/engines/libquery_engine-darwin-arm64.dylib.node)
Migration Engine        : migration-engine-cli 1a2506facaf1a4727b7c26850735e88ec779dee9 (at node_modules/prisma/node_modules/@prisma/engines/migration-engine-darwin-arm64)
Introspection Engine    : introspection-core 1a2506facaf1a4727b7c26850735e88ec779dee9 (at node_modules/prisma/node_modules/@prisma/engines/introspection-engine-darwin-arm64)
Format Binary           : prisma-fmt 1a2506facaf1a4727b7c26850735e88ec779dee9 (at node_modules/prisma/node_modules/@prisma/engines/prisma-fmt-darwin-arm64)
Default Engines Hash    : 1a2506facaf1a4727b7c26850735e88ec779dee9
Studio                  : 0.458.0

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 7
  • Comments: 20 (6 by maintainers)

Most upvoted comments

I think the cause of this issue is that Prisma is not searching the correct directory for the binary.

in my case I am compiling for AWS lambda, I get the error:

Query engine library for current platform \rhel-openssl-1.0.x\ could not be found.
You incorrectly pinned it to rhel-openssl-1.0.x

This probably happens because you built Prisma Client on a different platform.
(Prisma Client looked in \/var/task/src/libquery_engine-rhel-openssl-1.0.x.so.node\)

Searched Locations:

  /.prisma/client
  /home/runner/work/8bars/8bars/backend-v2/node_modules/@prisma/client
  /var/task
  /var/task/src
  /var/task/src
  /tmp/prisma-engines
  /var/task/src

You already added the platforms \debian-openssl-1.1.x\ \rhel-openssl-1.0.x\ to the \generator\ block
in the \schema.prisma\ file as described in https://pris.ly/d/client-generator
but something went wrong. That's suboptimal.

looking at the search paths it is missing

  /home/runner/work/8bars/8bars/backend-v2/node_modules/.prisma/client

The binaries are located here and not in the @prisma/client directory

+1 for @millsp just said. I used Mac M1, and installed Node under Rosetta. Then later I re-installed Node using Arm, started my server with Prisma, and encountered the error Query engine library for current platform "darwin-arm64" could not be found

The solution for my case is to re-run prisma generate under Arm

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.

Don’t know whether this helps anyone. But let me share my experience and fix for this error.

Some context:

  • I am running prisma on AWS Lambda. Runtime is node:16.
  • I am using two generated clients, one for cockroach one for sqlite.
    • In the end these end up in different lambdas, but I am developing them in the same repository
  • They are generated in node_modules/.prisma/sqlite and node_modules/.prisma/cockroach.
  • I am using aws-cdk/aws-lambda-nodejs to package lambdas.
  • I am manually deleting unnecessary generated things in order to decrease the bundle size
    • node_modules/prisma node_modules/@prisma/engines
    • and unnecessary libquery_engine files generated on the CI

In order to fix the Query engine library for current platform "rhel-openssl-1.0.x" could not be found. I had to explicitly set the PRISMA_QUERY_ENGINE_LIBRARY env var for the lambdas to point to the library files.

PRISMA_QUERY_ENGINE_LIBRARY: './node_modules/.prisma/sqlite/libquery_engine-rhel-openssl-1.0.x.so.node',
PRISMA_QUERY_ENGINE_LIBRARY: './node_modules/.prisma/cockroach/libquery_engine-rhel-openssl-1.0.x.so.node',

Little specific setup and an ugly solution but it works out in the end.

I’ve tried @VictorArowo’s approach, but still running into issues. Bizarrely, the error is pretty contradictory:

Query engine library for current platform "darwin-arm64" could not be found.
You incorrectly pinned it to darwin-arm64

In my particular implementation, I’m using this in a Yarn workspaces monorepo (test repo) with serverless-webpack-prisma. The same monorepo also reuses this Prisma client from a shared package in a Next.js site workspace, and Prisma works fine there, making me think my problem might actually be more specific to serverless-webpack-prisma (I’ve also asked there in this issue.

More detailed error message:

❮ sls invoke local -f videos -s local                                                                                              09:02 Lise
DOTENV: Could not find .env file.

asset src/videos.js 1.19 MiB [emitted] (name: src/videos)
  asset src/schema.prisma 4.61 KiB [emitted] [from: ../../packages/prisma/prisma/schema.prisma] [copied]
  cacheable modules 1.13 MiB
    modules by path ../../node_modules/@prisma/client/ 1.1 MiB
      ../../node_modules/@prisma/client/index.js 59 bytes [built] [code generated]
      ../../node_modules/@prisma/client/runtime/index.js 1.1 MiB [built] [code generated]
    ./src/videos.js 372 bytes [built] [code generated]
    ../../node_modules/.prisma/client/index.js 29.2 KiB [built] [code generated]
  + 21 modules
  webpack 5.74.0 compiled successfully in 375 ms

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


  Query engine library for current platform "darwin-arm64" could not be found.
You incorrectly pinned it to darwin-arm64

This probably happens, because you built Prisma Client on a different platform.
(Prisma Client looked in "/Users/joostschuur/Code/Personal/_Tests/yarn-workspaces-prisma-nextjs-serverless/services/backend/.webpack/service/src/libquery_engine-darwin-arm64.dylib.node")

Searched Locations:

  /Users/joostschuur/Code/Personal/_Tests/yarn-workspaces-prisma-nextjs-serverless/services/backend/.prisma/client
  /Users/joostschuur/Code/Personal/_Tests/yarn-workspaces-prisma-nextjs-serverless/node_modules/@prisma/client
  /Users/joostschuur/Code/Personal/_Tests/yarn-workspaces-prisma-nextjs-serverless/services/backend/.webpack/service
  /Users/joostschuur/Code/Personal/_Tests/yarn-workspaces-prisma-nextjs-serverless/services/backend/.webpack/service/src
  /Users/joostschuur/Code/Personal/_Tests/yarn-workspaces-prisma-nextjs-serverless/services/backend/.webpack/service/src
  /tmp/prisma-engines
  /Users/joostschuur/Code/Personal/_Tests/yarn-workspaces-prisma-nextjs-serverless/services/backend/.webpack/service/src

You already added the platform "darwin-arm64" to the "generator" block
in the "schema.prisma" file as described in https://pris.ly/d/client-generator,
but something went wrong. That's suboptimal.

Please create an issue at https://github.com/prisma/prisma/issues/new
    at RequestHandler.handleRequestError (webpack://backend/../../node_modules/@prisma/client/runtime/index.js?:28655:13)
    at PrismaClient._getDmmf (webpack://backend/../../node_modules/@prisma/client/runtime/index.js?:29727:23)
    at async PrismaClient._executeRequest (webpack://backend/../../node_modules/@prisma/client/runtime/index.js?:29648:22)
    at async consumer (webpack://backend/../../node_modules/@prisma/client/runtime/index.js?:29607:18)
    at async PrismaClient._request (webpack://backend/../../node_modules/@prisma/client/runtime/index.js?:29626:16)
    at async module.exports.handler (webpack://backend/./src/videos.js?:8:18) {
  clientVersion: '4.1.1',
  errorCode: undefined
}

I am getting this error in AWS lambda node16.x

Error: Query engine library for current platform "rhel-openssl-1.0.x" could not be found.
You incorrectly pinned it to rhel-openssl-1.0.x

Yes. This is happening intermittently, causing random requests to fail. We never specified binaryTargets in anyway prior to this. And specifying [“native”, “rhel-openssl-1.1.x”] also causes our builds to fail with function size errors. We have temporarily just pinned to binaryTargets = [“rhel-openssl-1.1.x”], but this obviously does not work for local development, as we have to switch to native.