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.

Unknown PRISMA_QUERY_ENGINE_LIBARARY linux-arm64-openssl-undefined

See original GitHub issue

Bug description

I was encountered with unknown query engine library error while I was trying to deploy my service on AWS Here is the error I got

MicrosoftTeams-image

Trying too much finding solution, but it seems Prisma can not detect proper query engine type

Setting binary target to native or arm does not solve the issue

How to reproduce

  1. Setup nestjs application with prisma
  2. Setup prisma client provider and output file in schema.prisma file
  3. Setup database source in schema.prisma file
  4. Select proper binary target
  5. Set PRISMA_QUERY_ENGINE_LIBRARY env variable pointing location of library engine
  6. Set PRISMA_CLI_BINARY_TARGETS
  7. Generate Prisma client
  8. Create docker image
  9. push and deploy docker image to AWS
  10. And you will get the error

Expected behavior

Prisma must specify right binary target it needs instead of displaying unknown

Prisma information

generator client {
  provider = "prisma-client-js"
  output   = "client"
  engineType = "library"
}

datasource db {
  provider = "mysql"
  url      = env("PRISMA_DB_URL")
}

// ... rest of my models
import { INestApplication, Injectable, OnModuleInit } from '@nestjs/common';
import { PrismaClient } from './client';

@Injectable()
export class PrismaService extends PrismaClient implements OnModuleInit {
  async onModuleInit() {
    await this.$connect();
  }

  async enableShutdownHooks(app: INestApplication) {
    this.$on('beforeExit', async () => {
      await app.close();
    });
  }
}

// PrismaService is then used to query database inside the project

Environment & setup

Setup Details
- OS: Amazon Linux 2
- Database: Aurora MySQL
- Node.js version: 16.16.0
- CPE OS Name: cpe:2.3:o:amazon:amazon_linux:2
- Kernel: Linux 4.14.281-212.5.02.amzn2.aarch64
- Architecture: arm64
# Environment Variables
PRISMA_DB_URL=mysql://username:password@host:port/designtool?database
ENV PRISMA_QUERY_ENGINE_LIBRARY=/app/prisma/engines/linux-arm64-openssl-3.0.x
ENV PRISMA_CLI_BINARY_TARGETS=linux-arm64-openssl-3.0.x

Prisma Version

# On development PC
prisma                  : 4.3.1
@prisma/client          : 4.3.1
Current platform        : windows
Query Engine (Node-API) : libquery-engine c875e43600dfe042452e0b868f7a48b817b9640b (at node_modules\@prisma\engines\query_engine-windows.dll.node)
Migration Engine        : migration-engine-cli c875e43600dfe042452e0b868f7a48b817b9640b (at node_modules\@prisma\engines\migration-engine-windows.exe)
Introspection Engine    : introspection-core c875e43600dfe042452e0b868f7a48b817b9640b (at node_modules\@prisma\engines\introspection-engine-windows.exe)
Format Binary           : prisma-fmt c875e43600dfe042452e0b868f7a48b817b9640b (at node_modules\@prisma\engines\prisma-fmt-windows.exe)
Format Wasm             : @prisma/prisma-fmt-wasm 4.3.0-32.c875e43600dfe042452e0b868f7a48b817b9640b
Default Engines Hash    : c875e43600dfe042452e0b868f7a48b817b9640b
Studio                  : 0.473.0

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
tt-mohsencommented, Sep 28, 2022

I am closing the issue, It’s fixed by installing openssl. Thanks

0reactions
jkomynocommented, Sep 28, 2022

I think the issue is that the Docker image you’re currently using doesn’t ship with openssl.

Consider a simpler Dockerfile:

# Dockerfile
FROM node:14-alpine

RUN apk add build-base
RUN apk --no-cache add curl

Build it via: docker build -t jkomyno/prisma-alpine .

Open an interactive local session via: docker run -it @jkomyno/prisma-alpine /bin/sh

Fetch the openssl version, if any:

/ # openssl version -v
/bin/sh: openssl: not found

Solution

The easiest fix is to drop alpine in favor of slim, a Debian-based image.

# Dockerfile
FROM node:14-slim

RUN apt-get -y update
RUN apt-get -y install build-essential
RUN apt-get -y install curl
# openssl version -v
OpenSSL 1.1.1n  15 Mar 2022

Please let us know whether the proposed solution works for you, so we can close this issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Provide precompiled binaries for ARM #861 - prisma ... - GitHub
Results in an error ! Unknown binaryTarget linux-arm64-openssl-undefined and no custom engine files were provided. The command '/bin/sh -c npx ...
Read more >
docker-compose up issue Using Docker Apple M1
Prisma seems to recognize I am on linux-arm but is unable to ... Undefined means you don't have openssl installed in the container....
Read more >
Prisma engines
Learn about Prisma internals and how it works "under the hood". Prisma tools are based on an engine-layer which manages the communication with...
Read more >
export node_options=--openssl-legacy-provider windows
On Linux, you need to edit your /etc/ssl/openssl.cnf to un-comment a few lines ... I was encountered with unknown query engine library error...
Read more >
M1 MacのDocker上のNestJSでPrismaを動かすまでに詰まっ ...
Error: Unknown binaryTarget linux-arm64-openssl-undefined and no custom ... ENV PRISMA_QUERY_ENGINE_BINARY=/prisma-engines/query-engine ...
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