Skip to content

Prisma and Netlify, binary is not downloaded automatically since 2.8.0 #4011

@divyenduz

Description

@divyenduz

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.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions