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
39.01k stars 1.53k forks source link

Query engine library for current platform "darwin" could not be found. #19636

Closed christopherpickering closed 1 year ago

christopherpickering commented 1 year ago

Bug description

@janpio in reference to #16334

This error message is still coming up, but I have not figured out how to reproduce it yet.

I am able to remove node_modules, install, and run again to resolve.

Here is the full log:

Full log ```sh /Users/christopherpickering/Library/Mobile Documents/com~apple~CloudDocs/Projects/prayercalendar.org/website_next/node_modules/@prisma/client/runtime/library.js:103 `,new G(i,this.config.clientVersion)}return this.platform=this.platform??await Be(),t}async resolveEnginePath(){let searchedLocations=[],enginePath;if(this.libQueryEnginePath)return{enginePath:this.libQueryEnginePath,searchedLocations};if(this.platform=this.platform??await Be(),__filename.includes("DefaultLibraryLoader"))return enginePath=We.default.join(Yo(),kt(this.platform,"fs")),{enginePath,searchedLocations};let dirname=eval("__dirname"),searchLocations=[We.default.resolve(dirname,"../../../.prisma/client"),this.config.generator?.output?.value??dirname,We.default.resolve(dirname,".."),We.default.dirname(this.config.datamodelPath),this.config.cwd,"/tmp/prisma-engines"];this.config.dirname&&searchLocations.push(this.config.dirname);for(let e of searchLocations)if(searchedLocations.push(e),Bs(`Searching for Query Engine Library in ${e}`),enginePath=We.default.join(e,kt(this.platform,"fs")),Pt.default.existsSync(enginePath))return{enginePath,searchedLocations};return enginePath=We.default.join(__dirname,kt(this.platform,"fs")),{enginePath,searchedLocations}}getFixedGenerator(){let e={...this.config.generator,binaryTargets:Zn(this.config.generator.binaryTargets,this.platform)};return ei(e)}};var Vs=R(require("os")),lp=J("prisma:client:libraryEngine:exitHooks"),Kr=class{constructor(){this.nextOwnerId=1;this.ownerToIdMap=new WeakMap;this.idToListenerMap=new Map;this.areHooksInstalled=!1;this.exitLikeHook=async t=>{lp(`exit event received: ${t}`);for(let r of this.idToListenerMap.values())await r();this.idToListenerMap.clear()}}install(){this.areHooksInstalled||(this.installExitEventHook("beforeExit"),this.installExitEventHook("exit"),this.installExitSignalHook("SIGINT"),this.installExitSignalHook("SIGUSR2"),this.installExitSignalHook("SIGTERM"),this.areHooksInstalled=!0)}setListener(t,r){if(r){let n=this.ownerToIdMap.get(t);n||(n=this.nextOwnerId++,this.ownerToIdMap.set(t,n)),this.idToListenerMap.set(n,r)}else{let n=this.ownerToIdMap.get(t);n!==void 0&&(this.ownerToIdMap.delete(t),this.idToListenerMap.delete(n))}}getListener(t){let r=this.ownerToIdMap.get(t);if(r!==void 0)return this.idToListenerMap.get(r)}installExitEventHook(t){process.once(t,this.exitLikeHook)}installExitSignalHook(t){process.once(t,async r=>{if(await this.exitLikeHook(r),process.listenerCount(r)>0)return;let i=Vs.default.constants.signals[r]+128;process.exit(i)})}};var Ne=J("prisma:client:libraryEngine");function up(e){return e.item_type==="query"&&"query"in e}function cp(e){return"level"in e?e.level==="error"&&e.message==="PANIC":!1}var Us=[...zn,"native"],Qs=0,Ti=new Kr,Zt=class extends Jr{constructor(r,n=new Gr(r)){super();try{this.datamodel=Js.default.readFileSync(r.datamodelPath,"utf-8")}catch(i){throw i.stack.match(/\/\.next|\/next@|\/next\//)?new G(`Your schema.prisma could not be found, and we detected that you are using Next.js. ^ PrismaClientInitializationError: Query engine library for current platform "darwin" could not be found. You incorrectly pinned it to darwin This probably happens, because you built Prisma Client on a different platform. (Prisma Client looked in "/Users/christopherpickering/Library/Mobile Documents/com~apple~CloudDocs/Projects/prayercalendar.org/website_next/node_modules/@prisma/client/runtime/libquery_engine-darwin.dylib.node") Searched Locations: /Users/christopherpickering/Library/Mobile Documents/com~apple~CloudDocs/Projects/prayercalendar.org/website_next/node_modules/.prisma/client /Users/christopherpickering/Library/Mobile Documents/com~apple~CloudDocs/Projects/prayercalendar.org/website_next/node_modules/@prisma/client /Users/christopherpickering/Library/Mobile Documents/com~apple~CloudDocs/Projects/prayercalendar.org/website_next/node_modules/@prisma/client /Users/christopherpickering/Library/Mobile Documents/com~apple~CloudDocs/Projects/prayercalendar.org/website_next/node_modules/.prisma/client /Users/christopherpickering/Library/Mobile Documents/com~apple~CloudDocs/Projects/prayercalendar.org/website_next/prisma /tmp/prisma-engines /Users/christopherpickering/Library/Mobile Documents/com~apple~CloudDocs/Projects/prayercalendar.org/website_next/node_modules/.prisma/client You already added the platforms "darwin", "debian-openssl-3.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. Please create an issue at https://github.com/prisma/prisma/issues/new at Gr.getLibQueryEnginePath (/Users/christopherpickering/Library/Mobile Documents/com~apple~CloudDocs/Projects/prayercalendar.org/website_next/node_modules/@prisma/client/runtime/library.js:103:3) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async Gr.loadLibrary (/Users/christopherpickering/Library/Mobile Documents/com~apple~CloudDocs/Projects/prayercalendar.org/website_next/node_modules/@prisma/client/runtime/library.js:77:790) at async Zt.loadEngine (/Users/christopherpickering/Library/Mobile Documents/com~apple~CloudDocs/Projects/prayercalendar.org/website_next/node_modules/@prisma/client/runtime/library.js:105:538) at async Zt.instantiateLibrary (/Users/christopherpickering/Library/Mobile Documents/com~apple~CloudDocs/Projects/prayercalendar.org/website_next/node_modules/@prisma/client/runtime/library.js:104:1832) { clientVersion: '4.14.0', errorCode: undefined } Node.js v20.2.0 [next-auth][warn][EXPERIMENTAL_API] `getServerSession` is used in a React Server Component. https://next-auth.js.org/configuration/nextjs#getServerSession} https://next-auth.js.org/warnings#EXPERIMENTAL_API - error unhandledRejection: Error: Query engine library for current platform "darwin" could not be found. You incorrectly pinned it to darwin This probably happens, because you built Prisma Client on a different platform. (Prisma Client looked in "/Users/christopherpickering/Library/Mobile Documents/com~apple~CloudDocs/Projects/prayercalendar.org/website_next/node_modules/@prisma/client/runtime/libquery_engine-darwin.dylib.node") Searched Locations: /Users/christopherpickering/Library/Mobile Documents/com~apple~CloudDocs/Projects/prayercalendar.org/website_next/node_modules/.prisma/client /Users/christopherpickering/Library/Mobile Documents/com~apple~CloudDocs/Projects/prayercalendar.org/website_next/node_modules/@prisma/client /Users/christopherpickering/Library/Mobile Documents/com~apple~CloudDocs/Projects/prayercalendar.org/website_next/node_modules/@prisma/client /Users/christopherpickering/Library/Mobile Documents/com~apple~CloudDocs/Projects/prayercalendar.org/website_next/node_modules/.prisma/client /Users/christopherpickering/Library/Mobile Documents/com~apple~CloudDocs/Projects/prayercalendar.org/website_next/prisma /tmp/prisma-engines /Users/christopherpickering/Library/Mobile Documents/com~apple~CloudDocs/Projects/prayercalendar.org/website_next/node_modules/.prisma/client You already added the platforms "darwin", "debian-openssl-3.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. Please create an issue at https://github.com/prisma/prisma/issues/new at Gr.getLibQueryEnginePath (/Users/christopherpickering/Library/Mobile Documents/com~apple~CloudDocs/Projects/prayercalendar.org/website_next/node_modules/@prisma/client/runtime/library.js:103:3) at async Gr.loadLibrary (/Users/christopherpickering/Library/Mobile Documents/com~apple~CloudDocs/Projects/prayercalendar.org/website_next/node_modules/@prisma/client/runtime/library.js:77:790) at async Zt.loadEngine (/Users/christopherpickering/Library/Mobile Documents/com~apple~CloudDocs/Projects/prayercalendar.org/website_next/node_modules/@prisma/client/runtime/library.js:105:538) at async Zt.instantiateLibrary (/Users/christopherpickering/Library/Mobile Documents/com~apple~CloudDocs/Projects/prayercalendar.org/website_next/node_modules/@prisma/client/runtime/library.js:104:1832) { digest: undefined } ```

How to reproduce

  1. Run a nextjs + prisma website. (npm run dev)
  2. Stop the website
  3. Work on some other sites that are ((remix || next) && prisma) (npm run dev)
  4. Run the nextjs site again after a few days

Expected behavior

No error :)

Prisma information

Here is the nextjs schema for the site the normally (only?) errors.

// Add your schema.prisma
generator client {
  provider        = "prisma-client-js"
  binaryTargets   = ["native", "debian-openssl-3.0.x"]
  previewFeatures = ["fullTextSearch"]
}

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

model Country {
  id                              Int            @id @default(autoincrement())
  name                            String?
  slug                            String?
  code                            String?
  code_two                        String?
  region                          String?
  religions                       String?
  climate                         String?
  terrain                         String?
  elevation                       String?
  population                      String?
  historicalInformation           String?
  nationality                     String?
  area                            String?
  areaComparative                 String?
  naturalResources                String?
  landUse                         String?
  populationDistribution          String?
  naturalHazards                  String?
  geographyNote                   String?
  ethnicGroups                    String?
  ageStructure                    String?
  medianAge                       String?
  populationGrowthRate            String?
  birthRate                       String?
  deathRate                       String?
  netMigrationRate                String?
  infantMortalityRate             String?
  lifeExpectancyAtBirth           String?
  currentHealthExpenditure        String?
  literacy                        String?
  countryName                     String?
  governmentType                  String?
  capital                         String?
  independence                    String?
  realGdpPurchasingPowerParity    String?
  realGdpGrowthRate               String?
  realGdpPerCapita                String?
  inflationRateConsumerPrices     String?
  agriculturalProducts            String?
  unemploymentRate                String?
  populationBelowPovertyLine      String?
  exportsPartners                 String?
  importsPartners                 String?
  internetUsers                   String?
  populationGrowthRateRank        String?
  birthRateRank                   String?
  deathRateRank                   String?
  infantMortalityRateRank         String?
  alcoholConsumptionPerCapitaRank String?
  realGdpPerCapitaRank            String?
  unemploymentRateRank            String?
  populationRank                  String?
  areaRank                        String?
  urbanization                    String?
  background                      String?
  continent                       String? //map-references
  languages                       String?
  persecutionRank                 String?
  persecutionSource               String?
  persecutionScore                String?
  persecutionType                 String?
  persecutionViolence             String?
  persecutionChurchLife           String?
  persecutionNationalLife         String?
  persecutionCommunityLife        String?
  persecutionFamilyLife           String?
  persecutionPrivateLife          String?
  persecutionDetails              String?
  progressScale                   String?
  primaryReligion                 String?
  percentChristian                String?
  securityLevel                   String?
  usaReligiousFreedom             String?
  tenForty                        String?
  progressText                    String?
  lat                             String?
  long                            String?
  flagUrl                         String?
  note                            String?
  internetCode                    String?
  humanRightsSummary              String?
  religiousFreedomSummary         String?
  assemblies                      Assembly[]
  assemblyCount                   String?
  assemblyNotes                   String?
  assemblyYear                    String?
  preachingPointCount             String?
  evangalistCount                 String?
  bibleTeacherCount               String?
  otherWorkerCount                String?
  partTimeCount                   String?
  visitorSummary                  String?
  believerTrend                   String?
  prayerRequests                  String?
  praiseRequests                  String?
  challengesFaced                 String?
  interestingInformation          String?
  mapRegion                       String?
  people                          Person[]
  ministries                      Ministry[]
  requests                        Request[]
  notes                           Note[]
  peopleGroups                    PeopleGroups[]
  peopleVisiting                  Person[]       @relation("VisitingToCountry")

  @@map(name: "countries")
}

model PeopleGroups {
  id                     Int      @id @default(autoincrement())
  country                Country? @relation(fields: [countryId], references: [id])
  countryId              Int?
  countryCode            String?
  peopleNameInCountry    String?
  continent              String?
  region                 String?
  peopleCluster          String?
  peopleNameGlobal       String?
  population             String?
  populationPercent      String?
  category               String?
  primaryLanguageName    String?
  primaryLanguageDialect String?
  numberOfLanguages      String?
  officialLanguage       String?
  bibleStatus            String?
  bibleYear              String?
  progressScale          String?
  leastReached           String?
  primaryReligion        String?
  securityLevel          String?
  rankOverall            String?
  rankProgress           String?
  rankPopulation         String?
  rankLocation           String?
  rankMinistryTools      String?
  countOfCountries       String?
  indigenous             String?
  naturalName            String?
  progressText           String?
  introductionHistory    String?
  whereLocated           String?
  livesLike              String?
  beliefs                String?
  needs                  String?
  prayer                 String?
  reference              String?
  summary                String?
  scriptureFocus         String?
  obstacles              String?
  howReach               String?
  prayForChurch          String?
  prayForPG              String?
}

model Assembly {
  id         Int       @id @default(autoincrement())
  name       String?
  country    Country?  @relation(fields: [countryId], references: [id])
  countryId  Int?
  state      String?
  city       String?
  zip        String?
  addressOne String?
  addressTwo String?
  schedule   String?
  website    String?
  websiteImg String?
  email      String?
  lat        String?
  long       String?
  requests   Request[]
  contacts   Person[]
  notes      Note[]

  @@index([countryId])
  @@map("assemblies")
}

model Person {
  id                    Int        @id @default(autoincrement())
  name                  String?
  email                 String?
  homePhone             String?
  cellPhone             String?
  country               Country?   @relation(fields: [countryId], references: [id])
  countryId             Int?
  state                 String?
  city                  String?
  zip                   String?
  createdAt             DateTime   @default(now()) @map("created_at")
  updatedAt             DateTime   @updatedAt @map("updated_at")
  addressOne            String?
  addressTwo            String?
  note                  String?
  website               String?
  websiteImg            String?
  lat                   String?
  long                  String?
  deceased              Boolean    @default(false)
  widowed               Boolean    @default(false)
  outOfFellowship       Boolean    @default(false)
  noLongerInService     Boolean    @default(false)
  historicalInformation String?
  requests              Request[]
  notes                 Note[]
  contactForAssembly    Assembly[]
  contactForMinistry    Ministry[]
  countriesVisited      Country[]  @relation("VisitingToCountry")

  @@map("people")
}

model Ministry {
  id                    Int       @id @default(autoincrement())
  name                  String?
  details               String?
  country               Country?  @relation(fields: [countryId], references: [id])
  countryId             Int?
  state                 String?
  city                  String?
  zip                   String?
  addressOne            String?
  addressTwo            String?
  historicalInformation String?
  createdAt             DateTime  @default(now()) @map("created_at")
  updatedAt             DateTime  @updatedAt @map("updated_at")
  cellPhone             String?
  email                 String?
  emailTwo              String?
  phone                 String?
  website               String?
  websiteImg            String?
  lat                   String?
  long                  String?
  category              Category? @relation(fields: [categoryId], references: [id])
  categoryId            Int?
  requests              Request[]
  contacts              Person[]
  notes                 Note[]

  @@map("ministries")
}

model Category {
  id         Int        @id @default(autoincrement())
  name       String?
  ministries Ministry[]
}

model Request {
  id          Int        @id @default(autoincrement())
  content     String?
  publishedAt DateTime?
  population  String?
  religion    String?
  language    String?
  title       String?
  area        String?
  people      Person[]
  assemblies  Assembly[]
  ministries  Ministry[]
  countries   Country[]
  createdAt   DateTime   @default(now()) @map(name: "created_at")
  updatedAt   DateTime   @updatedAt @map(name: "updated_at")

  @@index([publishedAt])
  // CREATE INDEX CONCURRENTLY ON requests USING gist (content gist_trgm_ops)
  @@index([content(ops: raw("gist_trgm_ops"))], type: Gist)
  @@map(name: "requests")
}

model Note {
  id          Int        @id @default(autoincrement())
  name        String?
  content     String?
  publishedAt DateTime?
  people      Person[]
  assemblies  Assembly[]
  ministries  Ministry[]
  countries   Country[]
  createdAt   DateTime   @default(now()) @map(name: "created_at")
  updatedAt   DateTime   @updatedAt @map(name: "updated_at")

  @@index([publishedAt])
  @@index([content(ops: raw("gist_trgm_ops"))], type: Gist)
  @@map(name: "notes")
}

model Url {
  id          Int      @id @default(autoincrement())
  createdAt   DateTime @default(now()) @map(name: "created_at")
  updatedAt   DateTime @updatedAt @map(name: "updated_at")
  views       Int?
  source      String
  destination String
  description String?
}

model Account {
  id                String  @id @default(cuid())
  userId            String
  type              String
  provider          String
  providerAccountId String
  refresh_token     String?
  access_token      String?
  expires_at        Int?
  token_type        String?
  scope             String?
  id_token          String?
  session_state     String?
  user              User    @relation(fields: [userId], references: [id], onDelete: Cascade)

  @@unique([provider, providerAccountId])
}

model Session {
  id           String   @id @default(cuid())
  sessionToken String   @unique
  userId       String
  expires      DateTime
  user         User     @relation(fields: [userId], references: [id], onDelete: Cascade)
}

model User {
  id            String    @id @default(cuid())
  name          String?
  email         String?   @unique
  emailVerified DateTime?
  image         String?
  approved      Int?
  accounts      Account[]
  sessions      Session[]
}

model VerificationToken {
  identifier String
  token      String   @unique
  expires    DateTime

  @@unique([identifier, token])
}
// Add your code using Prisma Client

Environment & setup

Prisma Version

4.14.0
christopherpickering commented 1 year ago

I am running this on icloud drive........ hehe icloud is probably offloading the file as they offload files I don't use for a few hrs or so it seems.

I just popped into the files and noticed that a bunch are offloaded (here meilisearch index):

image

I'm going to move off of icloud, close this issue and reopen if I get the error again.