prisma / prisma

Next-generation ORM for Node.js & TypeScript | PostgreSQL, MySQL, MariaDB, SQL Server, SQLite, MongoDB and CockroachDB
https://www.prisma.io
Apache License 2.0
38.95k stars 1.53k forks source link

Uncaught Expection : PrismaClientInitializationError: Query engine library for current platform "linux-arm64-openssl-1.1.x" could not be found. You incorrectly pinned it to linux-arm64-openssl-1.1.x #16947

Closed alexandregrare closed 1 year ago

alexandregrare commented 1 year ago

I get this error but it also says: You already added the platforms "linux-arm64-openssl-1.1.x", "rhel-openssl-1.0.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.

limegorilla commented 1 year ago

Similar problem - getting this when deploying to railway:

#11 95.23 GetConfigError: Unable to establish a connection to query-engine-node-api library. It seems there is a problem with your OpenSSL installation!
#11 95.23 Details: Unable to require(`/app/apps/keystone/node_modules/@prisma/internals/node_modules/@prisma/engines/libquery_engine-debian-openssl-3.0.x.so.node`)
#11 95.23  libssl.so.3: cannot open shared object file: No such file or directory
#11 95.23 [Context: getConfig]
janpio commented 1 year ago

Is this a new error, and were you using Prisma in older versions successfully before? Or are you new to Prisma and you are experiencing this problem when you first try to deploy?

It would be good if you could provide all the information the bug issue template asks for - we need that to understand what is going on.

limegorilla commented 1 year ago

Apologies I didn't make the issue.

No changes to my dependencies - I use this inside keystone and was just pushing a deploy out.

jkomyno commented 1 year ago

Hi @alexandregrare and @limegorilla, can you please post your schema.prisma file here and tell the version of Prisma you're using, as well as the specifics of the system you're running Prisma on (e.g. operating system, architecture, distro)?

I believe you've also set custom values in the binaryTargets attribute in your schema. Can you please remove this attribute altogether and try again the Prisma commands that failed, reporting here the results? Thanks.

alexandregrare commented 1 year ago

I cannot share you the schema but this is what was causing this issue. My schema.prisma did not include "linux-arm64-openssl-1.1.x" in the binaryTargets. Fixed by adding it and re-generating the client.

OS: macOS architecture: ARM

aqrln commented 1 year ago

Heads up that the error message may be partially misleading here, see https://github.com/prisma/prisma/issues/15292

limegorilla commented 1 year ago

Returning to this: To add context - running this on my local machine (M1 MB Pro) has no problems. Deploying to railway gets me:

#11 109.6 error /app/node_modules/keystone-app: Command failed.
#11 109.6 Exit code: 1
#11 109.6 Command: keystone postinstall
#11 109.6 Arguments:
#11 109.6 Directory: /app/node_modules/keystone-app
#11 109.6 Output:
#11 109.6 ✨ GraphQL and Prisma schemas are up to date
#11 109.6 GetConfigError: Unable to establish a connection to query-engine-node-api library. It seems there is a problem with your OpenSSL installation!
#11 109.6 Details: Unable to require(`/app/apps/keystone/node_modules/@prisma/internals/node_modules/@prisma/engines/libquery_engine-debian-openssl-3.0.x.so.node`)

#11 109.6  libssl.so.3: cannot open shared object file: No such file or directory
#11 109.6 [Context: getConfig]
#11 109.6
#11 109.6 Prisma CLI Version : 4.3.1
#11 109.6     at /app/apps/keystone/node_modules/@prisma/internals/dist/engine-commands/getConfig.js:154:12
#11 109.6     at n.e.run (/app/apps/keystone/node_modules/ts-pattern/dist/index.cjs:1:4927)
#11 109.6     at n.e.otherwise (/app/apps/keystone/node_modules/ts-pattern/dist/index.cjs:1:4570)
#11 109.6     at getConfigNodeAPI (/app/apps/keystone/node_modules/@prisma/internals/dist/engine-commands/getConfig.js:152:6)
#11 109.6     at async getConfig (/app/apps/keystone/node_modules/@prisma/internals/dist/engine-commands/getConfig.js:66:16)
#11 109.6     at async getGenerators (/app/apps/keystone/node_modules/@prisma/internals/dist/get-generators/getGenerators.js:100:18)
#11 109.6     at async Object.getGenerator (/app/apps/keystone/node_modules/@prisma/internals/dist/get-generators/getGenerators.js:289:22)
#11 109.6     at async generatePrismaClient (/app/apps/keystone/node_modules/@keystone-6/core/dist/artifacts-34627ad6.cjs.prod.js:488:21)
#11 109.6     at async Promise.all (index 0)
#11 109.6     at async Object.generateNodeModulesArtifacts (/app/apps/keystone/node_modules/@keystone-6/core/dist/artifacts-34627ad6.cjs.prod.js:485:3)
#11 109.6 info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

#11 ERROR: executor failed running [/bin/bash -ol pipefail -c yarn install --frozen-lockfile]: exit code: 1

My schema.prisma file is autogenerated by keystone, but is:

// This file is automatically generated by Keystone, do not modify it manually.
// Modify your Keystone config when you want to change this.

datasource postgresql {
  url               = env("DATABASE_URL")
  shadowDatabaseUrl = env("SHADOW_DATABASE_URL")
  provider          = "postgresql"
}

generator client {
  provider = "prisma-client-js"
  output   = "node_modules/.prisma/client"
}

model User {
  id        String   @id @default(cuid())
  name      String   @default("")
  email     String   @default("")
  subjectId String   @unique @default("")
  isAdmin   Boolean  @default(false)
  author    Author[] @relation("User_author")
}

model Tenant {
  id                                  String                    @id @default(cuid())
  name                                String                    @unique @default("")
  legal_company_name                  String                    @default("")
  company_number                      String                    @default("")
  phone                               String                    @default("")
  menu                                Json?
  email                               String                    @default("")
  description                         String                    @default("")
  site_url                            String                    @unique @default("")
  vercel_id                           String                    @default("")
  posts                               Post[]                    @relation("Post_tenant")
  authors                             Author[]                  @relation("Author_tenants")
  aboutpages                          AboutPage[]               @relation("AboutPage_tenants")
  servicepages                        Service[]                 @relation("Service_tenants")
  app_apple_id                        String                    @default("")
  app_google_id                       String                    @default("")
  contact_strapline                   String                    @default("")
  contact_show_office_options         String                    @default("Disable offices")
  contact_highlighted_office          Office?                   @relation("Tenant_contact_highlighted_office", fields: [contact_highlighted_officeId], references: [id])
  contact_highlighted_officeId        String?                   @map("contact_highlighted_office")
  offices                             Office[]                  @relation("Office_tenant")
  contact_content                     Json                      @default("[{\"type\":\"paragraph\",\"children\":[{\"text\":\"\"}]}]")
  contact_enable_google_maps          Boolean                   @default(false)
  contact_google_maps_config          Json?
  from_FrequentlyAskedQuestion_tenant FrequentlyAskedQuestion[] @relation("FrequentlyAskedQuestion_tenant")
  from_Policy_tenant                  Policy[]                  @relation("Policy_tenant")
  from_Sector_tenants                 Sector[]                  @relation("Sector_tenants")

  @@index([contact_highlighted_officeId])
}

model Author {
  id                      String      @id @default(cuid())
  name                    String      @default("")
  profile_photo_filesize  Int?
  profile_photo_extension String?
  profile_photo_width     Int?
  profile_photo_height    Int?
  profile_photo_id        String?
  tenants                 Tenant[]    @relation("Author_tenants")
  enable_author_page      Boolean     @default(false)
  seo_description         String      @default("")
  bio                     Json        @default("[{\"type\":\"paragraph\",\"children\":[{\"text\":\"\"}]}]")
  posts                   Post[]      @relation("Author_posts")
  is_manager              Boolean     @default(false)
  team                    String?
  job_title               String      @default("")
  phone                   String      @default("")
  email                   String      @default("")
  from_User_author        User[]      @relation("User_author")
  from_Policy_authors     Policy[]    @relation("Policy_authors")
  from_AboutPage_authors  AboutPage[] @relation("AboutPage_authors")
  from_Service_authors    Service[]   @relation("Service_authors")
  from_Sector_authors     Sector[]    @relation("Sector_authors")
}

model Post {
  id                         String    @id @default(cuid())
  title                      String    @default("")
  slug                       String    @unique @default("")
  tenant                     Tenant[]  @relation("Post_tenant")
  strapline                  String    @default("")
  category                   Category? @relation("Post_category", fields: [categoryId], references: [id])
  categoryId                 String?   @map("category")
  authors                    Author[]  @relation("Author_posts")
  status                     String?   @default("Draft")
  publish_time               DateTime  @default(now())
  show_hero                  Boolean   @default(false)
  hero_image_filesize        Int?
  hero_image_extension       String?
  hero_image_width           Int?
  hero_image_height          Int?
  hero_image_id              String?
  youtube_video              String?
  content                    Json      @default("[{\"type\":\"paragraph\",\"children\":[{\"text\":\"\"}]}]")
  tags                       Tag[]     @relation("Post_tags")
  seo_description            String    @default("")
  seo_use_header_image       String?
  from_Service_related_posts Service[] @relation("Service_related_posts")

  @@index([categoryId])
}

model Accreditation {
  id              String  @id @default(cuid())
  name            String  @unique @default("")
  description     String  @default("")
  link_to_site    String  @default("")
  image_filesize  Int?
  image_extension String?
  image_width     Int?
  image_height    Int?
  image_id        String?
}

model FrequentlyAskedQuestion {
  id       String   @id @default(cuid())
  question String   @default("")
  content  Json     @default("[{\"type\":\"paragraph\",\"children\":[{\"text\":\"\"}]}]")
  tenant   Tenant[] @relation("FrequentlyAskedQuestion_tenant")
}

model Policy {
  id                        String    @id @default(cuid())
  title                     String    @unique @default("")
  slug                      String    @unique @default("")
  tenant                    Tenant[]  @relation("Policy_tenant")
  description               String    @default("")
  updateDate                DateTime? @default(now())
  authors                   Author[]  @relation("Policy_authors")
  is_download_or_document   String?   @default("document")
  download_if_file_filesize Int?
  download_if_file_filename String?
  download_if_link          String    @default("")
  content_if_document       Json      @default("[{\"type\":\"paragraph\",\"children\":[{\"text\":\"\"}]}]")
}

model Tag {
  id          String @id @default(cuid())
  name        String @unique @default("")
  description String @default("")
  posts       Post[] @relation("Post_tags")
}

model InlineImage {
  id             String  @id @default(cuid())
  title          String  @default("No title provided")
  desc           String  @default("")
  file_filesize  Int?
  file_extension String?
  file_width     Int?
  file_height    Int?
  file_id        String?
}

model Office {
  id                                     String           @id @default(cuid())
  pretty_name                            String           @unique @default("")
  tenant                                 Tenant[]         @relation("Office_tenant")
  type                                   String?
  address                                String           @default("")
  phone                                  String           @default("")
  email                                  String           @default("")
  from_Tenant_contact_highlighted_office Tenant[]         @relation("Tenant_contact_highlighted_office")
  from_DigitalSignage_office             DigitalSignage[] @relation("DigitalSignage_office")
}

model Category {
  id                      String  @id @default(cuid())
  name                    String  @unique @default("")
  description             String  @default("")
  content                 Json    @default("[{\"type\":\"paragraph\",\"children\":[{\"text\":\"\"}]}]")
  show_hero_image_on_page Boolean @default(false)
  hero_image_filesize     Int?
  hero_image_extension    String?
  hero_image_width        Int?
  hero_image_height       Int?
  hero_image_id           String?
  from_Post_category      Post[]  @relation("Post_category")
}

model Client {
  id                      String  @id @default(cuid())
  name                    String  @unique @default("")
  slug                    String  @unique @default("")
  image_filesize          Int?
  image_extension         String?
  image_width             Int?
  image_height            Int?
  image_id                String?
  enable_page             Boolean @default(false)
  page_title              String  @default("")
  description             String  @default("")
  content                 Json    @default("[{\"type\":\"paragraph\",\"children\":[{\"text\":\"\"}]}]")
  show_hero_image_on_page Boolean @default(false)
  hero_image_filesize     Int?
  hero_image_extension    String?
  hero_image_width        Int?
  hero_image_height       Int?
  hero_image_id           String?
}

model AboutPage {
  id                   String   @id @default(cuid())
  title                String   @unique @default("")
  slug                 String   @unique @default("")
  tenants              Tenant[] @relation("AboutPage_tenants")
  strapline            String   @default("")
  content              Json     @default("[{\"type\":\"paragraph\",\"children\":[{\"text\":\"\"}]}]")
  show_hero            Boolean  @default(false)
  hero_image_filesize  Int?
  hero_image_extension String?
  hero_image_width     Int?
  hero_image_height    Int?
  hero_image_id        String?
  authors              Author[] @relation("AboutPage_authors")
  seo_description      String   @default("")
}

model Service {
  id                            String    @id @default(cuid())
  title                         String    @unique @default("")
  slug                          String    @unique @default("")
  display_on_services_page      String?   @default("Display")
  tenants                       Tenant[]  @relation("Service_tenants")
  strapline                     String    @default("")
  content                       Json      @default("[{\"type\":\"paragraph\",\"children\":[{\"text\":\"\"}]}]")
  hero_image_filesize           Int?
  hero_image_extension          String?
  hero_image_width              Int?
  hero_image_height             Int?
  hero_image_id                 String?
  authors                       Author[]  @relation("Service_authors")
  seo_description               String    @default("")
  related_services              Service[] @relation("Service_related_services")
  related_services_title        String    @default("See what other services we offer")
  related_services_blurb        String    @default("")
  related_posts                 Post[]    @relation("Service_related_posts")
  from_Service_related_services Service[] @relation("Service_related_services")
}

model Sector {
  id                   String   @id @default(cuid())
  title                String   @unique @default("")
  slug                 String   @unique @default("")
  tenants              Tenant[] @relation("Sector_tenants")
  strapline            String   @default("")
  content              Json     @default("[{\"type\":\"paragraph\",\"children\":[{\"text\":\"\"}]}]")
  hero_image_filesize  Int?
  hero_image_extension String?
  hero_image_width     Int?
  hero_image_height    Int?
  hero_image_id        String?
  authors              Author[] @relation("Sector_authors")
  seo_description      String   @default("")
}

model DigitalSignage {
  id           String  @id @default(cuid())
  name         String  @default("")
  disabled     String?
  office       Office? @relation("DigitalSignage_office", fields: [officeId], references: [id])
  officeId     String? @map("office")
  multi_screen String?
  desc         String  @default("")
  news_config  Json?

  @@index([officeId])
}

Unlike @alexandregrare, regenerating my schema did not seem to solve the problem

limegorilla commented 1 year ago

To add:

Seems like railway have updated their runtime (nixpacks) from Debian11 to Ubuntu 22 and switched to OpenSSL 3. I'll liase with them to see if this is a problem on their end

limegorilla commented 1 year ago

This is a Railway issue!

Seems like OpenSSL 3 is the only supported version of OpenSSL on Railway now by default:

Both mainline Alphine/Ubuntu have switched to OpenSSL 3, this means that your older Node projects (16 and below) might have issues. (Especially with Webpack and older versions of Prisma.)

The project I use (keystone) does make use of an older version of prisma - I've opened an issue there to update Prisma.

To fix:

Option 1 Enable the legacy Debian image You can set an env var in Railway with NIXPACKS_DEBIAN set to 1. This will make sure that > OpenSSL 1.1 will be installed.

Option 2 Enable OpenSSL 1.1 for Node. You can set this with setting an Env Var NODE_OPTIONS to --openssl-legacy-provider

Jolg42 commented 1 year ago

@alexandregrare The original error from this issue is now fixed. Could you try with a recent version of Prisma and see what error you get now?

daiho-nfq commented 1 year ago

I still got this error

Error

image

Schema image

Prisma version

"@prisma/client": "^5.0.0",
"prisma": "^5.0.0",

is it any relation when I put these 2 line of code in Dockerfile?

image
SevInf commented 1 year ago

@daiho-nfq have you tried doing what error message suggests and adding linux-arm64-openssl-1.1.x to your binary targets?

Jolg42 commented 1 year ago

Closing due to inactivity, @alexandregrare you can post a comment to let us know if we should reopen this.