prisma: Error: Unknown binaryTarget linux-arm64-openssl-undefined and no custom engine files were provided

    @janpio  I've recreated it with the following minimal setup.

Dockerfile

ARG FUNCTION_DIR="/var/task"
FROM node:16-slim

# Include global arg in this stage of the build
ARG FUNCTION_DIR

WORKDIR ${FUNCTION_DIR}
COPY . ${FUNCTION_DIR}

RUN yarn add prisma
RUN yarn prisma generate

prisma.schema

// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema

generator client {
  provider      = "prisma-client-js"
  binaryTargets = ["rhel-openssl-1.0.x", "linux-arm64-openssl-1.0.x"]
}

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

model User {
   objectID  String   @id @default(auto()) @map("_id") @db.ObjectId
}

docker-compose.yml

version: "3.9"
services:
  api:
    build: .
    volumes:
      - ./:/var/task

When running docker compose build you should get this error

Error: Unknown binaryTarget linux-arm64-openssl-undefined and no custom engine files were provided                               
#0 1.446 error Command failed with exit code 1.

_Originally posted by @jcampbell05 in https://github.com/prisma/prisma/issues/861#issuecomment-1310206111_

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 18 (4 by maintainers)

Most upvoted comments

for me it worked using node:16-slim version :

FROM node:16-slim
RUN apt-get update
RUN apt-get install -y openssl

Hi @damsog, manually adding openssl is no longer necessary in newer Prisma versions. Please install prisma@4.10.1 and try again without the additional Docker RUN command you’ve mentioned above.

@hotrungnhan, prisma@4.10.1 natively supports Linux Alpine on arm64 😃

So this error is unrelated to ARM and is caused by a lack of an installed SSL library. Some slim Docker images no longer come with a SSL library installed by default in order to keep the image as small as possible. This is why switching to a full sized image resolves this issue.

The fix is to simply install a SSL library.

Unfortunately the error from Prisma doesn’t provide any context that this is the issue. So I would suggest the following change:

  • Change the name of the Linux based package to indicate the number in the name is supposed to represent the version of the locally installed SSL library i.e “linux-rhel-ssl-1.0.0”. Wasn’t clear that this version number was related to that.
  • When a linux library has been selected (Either manually or automatically via “native”) then if a SSL library isn’t installed rather than returning “undefined” as the version number. Throw an error indicating that they lack a SSL library.

@janpio I’ve spent several hours trying to replicate this, but I’m not getting this error anymore. I haven’t changed anything on my end, so I’m not sure whether some other dependency was updated, or whether my computer was just caching something poorly.

But in either scenario, you should be free to close this. I can create a new ticket if I run into similar issues in the future.

@cesarvspr Yes I had to add the following line to my Dockerfile when using the node:16-slim image.

RUN apt-get update && apt-get install -y openssl libssl-dev

You may need to adjust this command for your distro if it uses another package manager.

@JameelKhan9 you also need to install openssl as Prisma needs the command line tool that installs to determine the version if it cannot do it via the headers.

i tried RUN apk add --update openssl && apk add --update libressl-dev && rm -rf /var/cache/apk/* to install openssl and libressl-dev but still didn’t work for alpine, had to change the base image to slim instead

@JameelKhan9 you also need to install openssl as Prisma needs the command line tool that installs to determine the version if it cannot do it via the headers.