Prisma: [Windows] "Photon binary for current platform windows could not be found" while running "npm run seed"

Created on 13 Sep 2019  路  25Comments  路  Source: prisma/prisma

  1. Run prisma2 init
  2. Choose template TypeScript > GraphQL + Auth > SQLite
  3. Run npm run seed

Result:
$ ts-node prisma/seed.ts (node:7708) UnhandledPromiseRejectionWarning: Error: Photon binary for current platform windows could not be found. Make sure to adjust the generator configuration in the schema.prisma file: generator photon { provider = "photonjs" platforms = ["native", "windows"] } Please run prisma2 generate for your changes to take effect. Note, that by providing `native`, Photon automatically resolves `windows`. Read more about deploying Photon: https://github.com/prisma/prisma2/blob/master/docs/core/generators/photonjs.md at NodeEngine.getPrismaPath (C:\Users\user\projects\playground\hello-prisma\node_modules\@generated\photon\runtime\index.js:3771:23) (node:7708) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1) (node:7708) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Tried to manually run prisma2 generate and then npm run seed. To no avail.

Prisma version: 2.0.0-preview-11
OS: Windows 10 Pro (x64)
Node version: 10.16.2
NPM version: 6.9.0

bu0-needs-info kinbug

Most helpful comment

@seed-of-apricot of course. In node_modules\@generatedphoton\runtime\index.js, search for the declaration for alternativePath (its in the getPrismaPath function at about line nbr 3770) and set its value to const alternativePath = 'C:\\Users\\serotonyn\\project\\node_modules\\@generated\\photon\\runtime\\query-engine-windows.exe'

All 25 comments

What version of Prisma are you using? (prisma2 v) If it's not [email protected], try upgrading that first.

I'm using [email protected].

Also, the last step of prisma2 init (npm run seed) requires ts-node and typescript to be installed globally.

I think this is related to https://github.com/prisma/prisma2/issues/548

Example fetches preview 9.1 by default so it would not work in windows as it requires preview-11.

@uranusexplorer can you please try running prisma2 dev(globally installed version) after the init flow and see whether it is working.

I don't have access to a windows machine right now so I can't test this.

I am getting the same error on every Mutation invoke. Also using preview 11.

@pantharshit00, prisma2 dev runs well. Yes, the example has 2.0.0-preview-9. Manually removed it and installed 2.0.0-preview-11. Getting same error for npm run seed.

Are you on a 32 bit system or a 64 bit system?

64

I get it to work by hardcoding the value of alternativePath and pointing it to the query-engine-windows.exe in the runtime folder.

@serotonyn Could you please tell me how to set the alternative path?

@seed-of-apricot of course. In node_modules\@generatedphoton\runtime\index.js, search for the declaration for alternativePath (its in the getPrismaPath function at about line nbr 3770) and set its value to const alternativePath = 'C:\\Users\\serotonyn\\project\\node_modules\\@generated\\photon\\runtime\\query-engine-windows.exe'

@serotonyn That worked, thank you!

Short investigation into this:

The original error message

(node:7708) UnhandledPromiseRejectionWarning: Error: Photon binary for current platform windows could not be found.

indeed comes from it not being able to get an alternativePath:
https://github.com/prisma/photonjs/blob/36d275c42ad36bd20619d4e47b605cb0306c06d7/packages/engine-core/src/NodeEngine.ts#L210-L217

We missed to adapt the resolveAlternativeBinaryPath method for Windows to add the necessary .exe:
https://github.com/prisma/photonjs/blob/36d275c42ad36bd20619d4e47b605cb0306c06d7/packages/engine-core/src/NodeEngine.ts#L170-L180

But we probably also missed resolvePrismaPath
https://github.com/prisma/photonjs/blob/36d275c42ad36bd20619d4e47b605cb0306c06d7/packages/engine-core/src/NodeEngine.ts#L147-L165
which would lead to this not even being triggered.

Do you agree @divyenduz? Should be simple enough to fix in a quick PR from me.

(We should probably double check all mentions of query-engine- in the codebase for this)

@janpio Yup, sounds like it 馃憤

I'm having the same issue using the latest dependencies for prisma2, nexus, and nexus-prisma.

The issue

The issue is coming from filePath in .../node_modules\@generated\photon\runtime\index.js. If I print the result of filePath, the result is .../node_modules\@generated\photon\runtime\query-engine-linux-musl-libssl1.1.0, and it should be .../node_modules\@generated\photon\runtime\query-engine-windows.exe.

The hack

Replace this:

const filePath = path.join(__dirname, `query-engine-${platform}`);

For this:

const filePath = path.join(__dirname, `query-engine-windows.exe`);

The problem

The problem is that each time I do changes in my schema.prisma using prisma2 dev, it generates a new file and replaces the old one, and the fix goes away.


I would appreciate if someone could fix this ASAP.

~Came here to add that I was also experiencing this issue on MacOS (darwin), and can confirm it's resolved on [email protected], incase anyone else finds themselves here when investigating this issue locally.~

~Looks like I was wrong here. I'm seeing these failures on MacOS on the latest alpha of prisma2.~

Turns out it was an issue with my tooling on my end.

We currently think this might already be fixed by a pending change, will test and let you know when the change is available in alpha for confirmation.

This now works fine with preview-13.

Please let us know if this is not true for you, and we can reopen this issue and investigate further.

Bump, as I'm running into this issue again. Same issue & platform as mentioned in OP.

Fixed by hard-coding the alternativePath.

@embiem Can you please tell me which version of Prisma 2 are you using?

@pantharshit00 I'm currently on "2.0.0-preview018.1" for prisma2 and @prisma/photon

@embiem @amursky Is this still an issue?

@divyenduz I'm using 2.0.0-preview019. Everything is fine.

Thanks for the update, I am closing this one then.

minor comment for recent Google arrivals... in Prisma 2 the syntax is like this now:

generator client {
  provider       = "prisma-client-js"
  binaryTargets  = ["native", "windows"]
}
Was this page helpful?
0 / 5 - 0 ratings

Related issues

15chrjef picture 15chrjef  路  24Comments

yovanoc picture yovanoc  路  28Comments

ranjan-purbey picture ranjan-purbey  路  25Comments

schickling picture schickling  路  41Comments

iherger picture iherger  路  26Comments