prisma-client-js icon indicating copy to clipboard operation
prisma-client-js copied to clipboard

Query engine binary could not be found

Open iherger opened this issue 6 years ago • 19 comments

Bug description

When deploying to Dokku on DigitalOcean, I get the following error:

Invalid `prisma.event.findMany()` invocation:

Query engine binary for current platform "debian-openssl-1.1.x" could not be found.
This probably happens, because you built Prisma Client on a different platform.
(Prisma Client looked in "/app/node_modules/@prisma/client/runtime/query-engine-debian-openssl-1.1.x")

You already added the platforms "native", "debian-openssl-1.1.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.

Please create an issue at https://github.com/prisma/prisma-client-js/issues/new",

(Locally, on MacOS, everything works well).

Prisma information

@prisma/client: preview025 @prisma/cli: preview025

Environment & setup

  • Dokku on DigitalOcean (Ubuntu 18.04)
  • Database: PostgreSQL on DigitalOcean

iherger avatar Mar 31 '20 07:03 iherger

Similar to https://github.com/prisma/prisma2/issues/2015 we really need to find the cause

Sytten avatar Mar 31 '20 11:03 Sytten

@iherger Are you using yarn?

pantharshit00 avatar Apr 01 '20 17:04 pantharshit00

@pantharshit00 , yes, using yarn.

This is an intermittent error, and unfortunately, I have no indications as to when it happens and when not. It has reappeared again after upgrading to prisma 2 beta.

iherger avatar Apr 01 '20 19:04 iherger

Might also be related to https://github.com/prisma/prisma/issues/2082.

heymartinadams avatar Apr 07 '20 17:04 heymartinadams

Getting the same issue with docker . Not using netlify ;)

emroot avatar Apr 13 '20 20:04 emroot

I ran into this issue deploying to Heroku as well. I also tried "heroku-postbuild": "yarn prisma generate" which did regenerate the client, but before their cleanup task and did not solve the problem. I assume they are removing binaries during cleanup.

To get around this, I ssh'ed into the box and ran the generate cmd.

evanheisler avatar Apr 16 '20 00:04 evanheisler

@evanheisler For the Heroku issue, please refer here: https://github.com/prisma/prisma/issues/1540. It should not happen and please open a new issue if you are still encountering it. An example Heroku deployment can be found in our end to end test repository: https://github.com/prisma/prisma2-e2e-tests/tree/master/platforms/heroku

@emroot Can you please share your dockerfile. Also, please note that if your host and the docker vm are different environments, you will need to specify both in the binary target so that cli explicitly downloads and persist binary for both OS like so:

generator prisma {
  provider = "prisma-client-js"
  binaryTargets = ["native","darwin","debian-openssl-1.1.x"]
}

For the yarn issue, we have noticed it many times but still lack a concrete reproduction so that we may patch in our system or otherwise open a PR to yarn to solve the issue. If anyone can provide a reproduction which is reliable enough, please post it here.

pantharshit00 avatar Apr 19 '20 11:04 pantharshit00

Hey @pantharshit00 I'm having the same issue with Docker. My generator looks exactly like the one you showed:

generator client {
  provider = "prisma-client-js"
  binaryTargets = ["native", "darwin", "debian-openssl-1.1.x"]
}

My Dockerfile looks like this:

FROM node:12.16.2-alpine

ENV LANG=C.UTF-8
ENV GLIBC_VERSION 2.30-r0

RUN apk add --update curl && \
  curl -Lo /etc/apk/keys/sgerrand.rsa.pub https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub && \
  curl -Lo glibc.apk "https://github.com/sgerrand/alpine-pkg-glibc/releases/download/${GLIBC_VERSION}/glibc-${GLIBC_VERSION}.apk" && \
  curl -Lo glibc-bin.apk "https://github.com/sgerrand/alpine-pkg-glibc/releases/download/${GLIBC_VERSION}/glibc-bin-${GLIBC_VERSION}.apk" && \
  apk add glibc-bin.apk glibc.apk && \
  /usr/glibc-compat/sbin/ldconfig /lib /usr/glibc-compat/lib && \
  echo 'hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4' >> /etc/nsswitch.conf && \
  apk del curl && \
  rm -rf glibc.apk glibc-bin.apk /var/cache/apk/*

WORKDIR /usr/src/app

# install dependencies

COPY package.json .
COPY yarn.lock .
RUN yarn install --frozen-lockfile --no-cache

# copy over source code
COPY prisma ./prisma
COPY src ./src
COPY tsconfig.json ./tsconfig.json

EXPOSE 5000

RUN yarn generate:client
RUN yarn build

CMD ["yarn", "start:prod"]

Shelling into the container, I see there is no query-engine-debian-openssl-1.1.x folder, but there is a query-engine-darwin. I tried just removing the other two binary targets and just having debian-openssl but had the same issue...

Michael-M-Judd avatar Apr 19 '20 14:04 Michael-M-Judd

@Michael-M-Judd Alpine is not supported by us right now, even if you install glibc on it. Please use node-slim for now or provide your binaries via environment variables: https://github.com/prisma/prisma/issues/1840

pantharshit00 avatar Apr 19 '20 15:04 pantharshit00

@Michael-M-Judd Alpine is not supported by us right now, even if you install glibc on it. Please use node-slim for now or provide your binaries via environment variables: prisma/prisma#1840

I also tried using node-slim and have the exact same error

Michael-M-Judd avatar Apr 19 '20 15:04 Michael-M-Judd

I have set NODE_MODULES_CACHE to false and I haven't had the issue since.

iherger avatar Apr 19 '20 15:04 iherger

@Michael-M-Judd Can you please share the dockerfile that you used with node-slim. That way I can try a reproduction. If you can share a git repo with the reproduction, that would be awesome.

pantharshit00 avatar Apr 21 '20 03:04 pantharshit00

I ran across this issue while following along the redwoodjs turotial. The issue was related to the node version. Namely, I solved the issue by switching from node@14 to node@13. To provide more insight, if you haven't done so already, get nvm. Subsequently install the appropriate version with nvm install 13 and switch to it with nvm use 13.

mateja176 avatar May 21 '20 22:05 mateja176

@mateja176 Yeah, we recently hit a nodejs bug. Please read: https://github.com/prisma/prisma/issues/2361

We have implemented a workaround for node 14 and it should work now. I think it will get automatically fixed when redwood updates the Prisma verson

pantharshit00 avatar May 25 '20 10:05 pantharshit00

I think i am having related issue.

schema.prisma

generator client {
  provider = "prisma-client-js"
  binaryTargets = ["native", "debian-openssl-1.1.x"]
}

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

Versions

"dependencies": {
  "@nexus/schema": "^0.14.0",
  "@prisma/client": "^2.0.1",
  "nexus-prisma": "^0.14.0"
},
"devDependencies": {
  "@prisma/cli": "^2.0.1",
}

npm 6.14.4 node v12.18.0

OS NAME="Alpine Linux" ID=alpine VERSION_ID=3.11.6 PRETTY_NAME="Alpine Linux v3.11" HOME_URL="https://alpinelinux.org/" BUG_REPORT_URL="https://bugs.alpinelinux.org/"

Error message

Query engine binary for current platform "linux-musl" could not be found.↵This probably happens, because you built Prisma Client on a different platform.↵(Prisma Client looked in "/app/node_modules/@prisma/client/runtime/query-engine-linux-musl")↵↵Files in /app/node_modules/@prisma/client/runtime:↵↵  Dataloader.d.ts↵  browser-chalk.d.ts↵  browser-terminal-link.d.ts↵  browser.d.ts↵  dmmf-types.d.ts↵  dmmf.d.ts↵  error-types.d.ts↵  externalToInternalDmmf.d.ts↵  getLogLevel.d.ts↵  getPrismaClient.d.ts↵  highlight↵  index.d.ts↵  index.js↵  index.js.map↵  mergeBy.d.ts↵  query.d.ts↵  transformDmmf.d.ts↵  utils↵  visit.d.ts↵↵You already added the platform "native" 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-client-js/issues/new

lauriskuznecovs avatar Jun 17 '20 14:06 lauriskuznecovs

@lauriskuznecovs Can you please open a new issue with a minimal reproduction? Thanks!

Also, try following generator block for alpine:

generator client {
  provider = "prisma-client-js"
  binaryTargets = ["native", "linux-musl"]
}

pantharshit00 avatar Jun 24 '20 14:06 pantharshit00

Thanks, @pantharshit00 seems like it fixed my issue.

lauriskuznecovs avatar Jun 25 '20 21:06 lauriskuznecovs

I solved this issue for myself by overriding the node.__dirname Webpack setting inside next.config.js.

// node.config.js

module.exports = {
  // stuff here
  webpack: (config, { buildId, dev, isServer, defaultLoaders, webpack }) => {
    config.node.__dirname = false;
    return config;
  },
};

This solution was first proposed here.

Related issues:

  • https://github.com/prisma/prisma/issues/2303
  • https://github.com/prisma/prisma-client-js/issues/616
  • https://github.com/prisma/prisma/issues/2195

colinhacks avatar Oct 23 '20 01:10 colinhacks

I am going to close this as its been 3 months now and there is no activity here.

Please reply if you want us to take another look.

pantharshit00 avatar Jan 13 '21 19:01 pantharshit00