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.

Prisma and Netlify, binary is not downloaded automatically since 2.8.0

See original GitHub issue

Bug description

Since Prisma 2.8.0 the following schema.prisma configuration doesn’t download the binary in Netlify CI. To clarify, a binary is downloaded if you are running it locally.

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

How to reproduce

  1. Deploy this project to netlify https://github.com/divyendu-test/p2-netlify-ci (fulfil the required env var from Netlify UI)
  2. It is on Prisma version 2.8.0 or later (I also tried it on the latest dev 2.10.0-dev.55) and the service URL after the first deploy should fail with
    {"errorType":"Error","errorMessage":"\nInvalid `prisma.user.deleteMany()` invocation in\n/var/task/src/functions/index.js:6:21\n\n\n Query engine binary for current platform \"rhel-openssl-1.0.x\" could not be found.\nThis probably happens, because you built Prisma Client on a different platform.\n(Prisma Client looked in \"/var/task/src/node_modules/@prisma/client/runtime/query-engine-rhel-openssl-1.0.x\")\n\nFiles in /var/task/src/node_modules/@prisma/client/runtime:\n\n index.d.ts\n index.js\n index.js.map\n\nYou already added the platform \"native\" to the \"generator\" block\nin the \"schema.prisma\" file as described in https://pris.ly/d/client-generator,\nbut something went wrong. That's suboptimal.\n\nPlease create an issue at https://github.com/prisma/prisma-client-js/issues/new","trace":["Error: ","Invalid `prisma.user.deleteMany()` invocation in","/var/task/src/functions/index.js:6:21","",""," Query engine binary for current platform \"rhel-openssl-1.0.x\" could not be found.","This probably happens, because you built Prisma Client on a different platform.","(Prisma Client looked in \"/var/task/src/node_modules/@prisma/client/runtime/query-engine-rhel-openssl-1.0.x\")","","Files in /var/task/src/node_modules/@prisma/client/runtime:",""," index.d.ts"," index.js"," index.js.map","","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"," at qw.request (/var/task/src/node_modules/@prisma/client/runtime/index.js:210:293)"]}
    
  3. Change the Prisma CLI/Client version to 2.7.0 and re-deploy
  4. It should work as expected (please do “clear cache and deploy” from netlify UI)
  5. Note that if you have a project that has the binary already, netlify’s cache might provide the binary, so please use “clear cache and deploy” for trying out each version

Expected behavior

  1. 2.8.0 should also download the required netlify binary if 2.7.0 does.

Additional context

  1. The workaround of adding the specific binary works

    generator client {
      provider      = "prisma-client-js"
      binaryTargets = ["native", "rhel-openssl-1.0.x"]
    }
    
  2. A sample SQL/Schema that this can be tried with

    CREATE TABLE "public"."User" (
       "email" text NOT NULL,
       "id" text NOT NULL,
       "name" text,
       PRIMARY KEY ("id")
    );
    
    datasource db {
      provider = "postgresql"
      url      = env("NETLIFY_BETA_PG_URL")
    } 
    
      generator client {
      provider      = "prisma-client-js"
      binaryTargets = ["native"]
    }
    
    model User {
      id    String  @id @default(cuid())
      email String  @unique
      name  String?
    }
    
  3. DM me for database credentials if you are trying this from within Prisma.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:4
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
thedavidpricecommented, Nov 5, 2020

Confirming my local and deploy tests (Netlify and Vercel) are successfull using Prisma v2.11.0-dev.40 in the case where binaryTarget = “native”.

Thanks again! 🚀

Read more comments on GitHub >

github_iconTop Results From Across the Web

Netlify Deployment | Unfound Prisma engine binary
RedwoodJS Tutorial: Netlify Deployment | Unfound Prisma engine ... Prisma and Netlify, binary is not downloaded automatically since 2.8.0.
Read more >
Prisma Client Binary Not Copied for Netlify Lambda Functions ...
I'm trying to deploy a GraphQL server using Netlify Functions; my app works in development, but doesn't work in production because the necessary...
Read more >
Prisma Client Binary Not Copied for Netlify Lambda Functions ...
Bug description I'm trying to deploy a GraphQL server using Netlify Functions; my app works in development, but doesn't work in production because...
Read more >
different outcomes between CLI deployment and github auto ...
I have one project that I can deploy two different ways. The first one works, the second does not. I used netlify functions:create...
Read more >
Netlify won't deploy my Next.js+Prisma app
I'm having trouble deploying this basic Next.js app with Prisma to ... Prisma Client Binary Not Copied for Netlify Lambda Functions (For ...
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