Skip to content

Cloning a project with checked in node_modules (from another platform) leads to platform engine not being present #7848

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
janpio opened this issue Jun 24, 2021 · 3 comments · Fixed by #19330
Labels
bug/2-confirmed Bug has been reproduced and confirmed. domain/client Issue in the "Client" domain: Prisma Client, Prisma Studio etc. kind/bug A reported bug. tech/typescript Issue for tech TypeScript. topic: error
Milestone

Comments

@janpio
Copy link
Contributor

janpio commented Jun 24, 2021

Reproduction:

  1. Clond https://github.com/janpio/prisma-update
  2. In prisma2, run npm install
  3. Run node src/index.js
  4. Run a GraphQL query:
# Write your query or mutation here
query($workDayId: ID!) {
  bills(workDayId: $workDayId) {
    id
    createdAt
    closedAt
    status
    registered
    tableData {
      id
    }
    orders {
      id
    }
    payments {
      id
      bill {
        id
      }
    }
    value
    discount
    discountReason
    wasReopen
    reopenBills {
      id
    }
  }
}

with param

{
  "workDayId": "ckoqcen7q3035zas4qyi3wik3"
}
  1. Observe:
λ node src/index.js
Server is running on http://localhost:4001
Error:
Invalid `prisma.bill.findMany()` invocation:


  Query engine binary for current platform "windows" could not be found.
This probably happens, because you built Prisma Client on a different platform.
(Prisma Client looked in "C:\Users\Jan\Documents\throwaway\juliaaleixo\prisma-update\prisma2\node_modules\@prisma\client\runtime\query-engine-windows.exe")

Searched Locations:

  C:\Users\Jan\Documents\throwaway\juliaaleixo\prisma-update\prisma2\node_modules\.prisma\client
  /Users/juliaaleixo/Documents/GitHub/prisma-update/prisma2/node_modules/@prisma/client
  C:\Users\Jan\Documents\throwaway\juliaaleixo\prisma-update\prisma2\node_modules\@prisma\client
  C:\Users\Jan\Documents\throwaway\juliaaleixo\prisma-update\prisma2\node_modules\.prisma\client
  C:\Users\Jan\Documents\throwaway\juliaaleixo\prisma-update\prisma2
  /tmp/prisma-engines
  C:\Users\Jan\Documents\throwaway\juliaaleixo\prisma-update\prisma2\node_modules\.prisma\client


To solve this problem, add the platform "windows" to the "binaryTargets" attribute in the "generator" block in the "schema.prisma" file:
generator client {
  provider      = "prisma-client-js"
  binaryTargets = ["native"]
}

Then run "prisma generate" for your changes to take effect.
Read more about deploying Prisma Client: https://pris.ly/d/client-generator
    at cb (C:\Users\Jan\Documents\throwaway\juliaaleixo\prisma-update\prisma2\node_modules\@prisma\client\runtime\index.js:35107:17)
    at async Promise.all (index 0)
    at async Promise.all (index 0)

Theory: npm install recognizes that dependency is there and up to date, and does not run any postinstall that would regenerate the Client for this platform.

@janpio janpio changed the title Cloning a project with checked in node_modules (from another platform) leads to platform binary not being present Cloning a project with checked in node_modules (from another platform) leads to platform engine not being present Jun 24, 2021
@janpio janpio added the domain/client Issue in the "Client" domain: Prisma Client, Prisma Studio etc. label Jun 30, 2021
@pantharshit00 pantharshit00 added bug/2-confirmed Bug has been reproduced and confirmed. kind/bug A reported bug. topic: package manager labels Jul 25, 2021
@pantharshit00
Copy link
Contributor

I can reproduce this. Not sure how we can trigger the hook here. Workaround is to run prisma generate manually.

@janpio
Copy link
Contributor Author

janpio commented Jan 28, 2023

This is a fundamental limitation. All we could do here is to improve the error message, and point out that the engine is only found for a different operation system and maybe link somewhere, where we explain this more (binaryTargets etc).

@millsp
Copy link
Member

millsp commented May 31, 2023

Hey, we wanted to give you an update about this. We have around 10 issues that we have identified to be in the "engine not found" category. Looking at these, we learned that there are four main categories responsible for these errors:

  • Your client was generated with native (default) on one platform, but used on a different platform at runtime.
  • You pinned binaryTargets incorrectly, and the correct engine was therefore not included at runtime.
  • A bundler/framework changed the Prisma Client but did not copy the necessary engine for the runtime.
  • Deployment/tooling did not copy the engine correctly so the correct engine was not included at runtime.

These cases were previously not detected. On top of that, the error messages were confusing and were neither helpful for you or us. With that, it is likely that many of the cases above overlapped each other. So while we cannot fix a missing engine, we can detect how and why it happened. Thanks to that, we now display more useful errors to help you out of trouble. And in some cases, we will ask some input from you to learn more about your project so we can further improve.

If something is still off for you, feel free to create a new issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/2-confirmed Bug has been reproduced and confirmed. domain/client Issue in the "Client" domain: Prisma Client, Prisma Studio etc. kind/bug A reported bug. tech/typescript Issue for tech TypeScript. topic: error
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants