prisma: Upgrade from 4.12 to 4.15: Prisma can no longer find schema.prisma file when launching Electron packaged executable
Bug description
App written in Electron. Build steps to produce .exe all still work as expected. However, on launch, error is thrown saying Prisma cannot find schema.prisma. Only change is upgrade from 4.12 to 4.15. Bundler still places all the relevant files (query-engine & schema.prisma) in the correct locations. No problems when running in Dev.
How to reproduce
Expected behavior
No response
Prisma information
generator client {
provider = "prisma-client-js"
output = "../src/main/db/generated"
previewFeatures = ["multiSchema"]
binaryTargets = ["native"]
}
Environment & setup
Windows 10 SQL Server Node: 18.12.1
Prisma Version
Prisma Version 4.15
About this issue
- Original URL
- State: open
- Created a year ago
- Reactions: 1
- Comments: 15 (6 by maintainers)
@millsp
Had to do something similar to @lemonpole (CopyWebpackPlugin) to get this to work. Some notes:
The reason this used to work (4.12) is you used “findSync” to find the same “alternatePaths” under the cwd. However, findSync() looked for the alternatePaths as patterns under the cwd, rather than literal paths =>“main\db\generated\schema.prisma” was found somewhere in the cwd. Unless you think it’s a good idea regressing to matching patterns again, I think slightly hacky web packing like @lemonpole and I have done might be simplest.
Hey @janpio I’ve created a boilerplate repo based off of my private project which is where I am facing the issue.
https://github.com/lemonpole/electron-forge-prisma
It has two branches:
mainbranch where you can see things working as expected usingprisma@4.9.x.build/prisma-upgradebranch where it is possible to reproduce the issue.The application renders a countries dropdown which is populated using Prisma backed by SQLite3.
I hope this helps, and disclaimer, I’ve only tested this on Windows.
After building the production bundle you can open it using:
Thanks @dfoley-greenlight and @lemonpole, this is really helpful information.
@millsp Will try to give feedback today, tomorrow at latest
Hey @millsp yes that is correct.
I’ll defer to OP on confirming whether the fix worked for them as their issue seems genuine.
Whereas mine, I’ve come to realize, is due to a limitation with Electron Forge and how it handles extraneous files by placing them in a nested
resourcesdirectory.Also, thanks a lot for your reply, it’s invaluable for me to be able to understand these problems better and improve things down the line.
Hey @millsp thanks so much for the quick turnaround on this. It did not work for me, unfortunately, but after messing with my build system today (thanks to your update) I was able to come up with a sufficient workaround.
To sum up, (and for anybody else who stumbles upon this issue), Electron Forge is placing the
schema.prismafile under a nestedresourcesdirectory. Apparently, the Electron packaging tool only picks up extra files under this directory. So it’s more a limitation with Electron Forge than an issue with Prisma itself, so I’m satisfied with the fix.Using CopyWebpackPlugin I’m able to copy it to the expected location.
I will work on pushing these changes to the reproduction repo along with attempting to add some basic support for Linux.