TypeError when using `npx prisma generate` with custom engine binaries
See original GitHub issueBug description
npx prisma generate fails with TypeError: Cannot read property 'filter' of undefined
How to reproduce
Repro on CentOS 8:
- Download starter project from Quickstart with Typescript.
curl -L https://pris.ly/quickstart | tar -xz --strip=2 quickstart-master/typescript/starter
- Download and extract binaries:
mkdir vendor-bins && cd vendor-bins \
&& wget https://binaries.prisma.sh/2.1.x/latest/debian-openssl-1.1.x/introspection-engine.gz \
https://binaries.prisma.sh/2.1.x/latest/rhel-openssl-1.1.x/migration-engine.gz \
https://binaries.prisma.sh/2.1.x/latest/rhel-openssl-1.1.x/prisma-fmt.gz \
https://binaries.prisma.sh/2.1.x/latest/rhel-openssl-1.1.x/query-engine.gz \
&& gunzip *.gz \
&& chmod +x ./* \
&& cd ..
- Set environment variables
export PRISMA_MIGRATION_ENGINE_BINARY="$PWD/vendor-bins/migration-engine" \
&& export PRISMA_QUERY_ENGINE_BINARY="$PWD/vendor-bins/query-engine" \
&& export PRISMA_INTROSPECTION_ENGINE_BINARY="$PWD/vendor-bins/introspection-engine" \
&& export PRISMA_FMT_BINARY="$PWD/vendor-bins/prisma-fmt"
- Install project
npm install
- Attempt to generate the client
$ DEBUG="*" npx prisma generate
prisma:tryLoadEnv Environment variables not found at null +0ms
prisma:tryLoadEnv Environment variables loaded from ./prisma/.env +2ms
Environment variables loaded from prisma/.env
download Using env var PRISMA_QUERY_ENGINE_BINARY for binary query-engine, which points to /home/kyle/starter/vendor-bins/query-engine +0ms
download Using env var PRISMA_MIGRATION_ENGINE_BINARY for binary migration-engine, which points to /home/kyle/starter/vendor-bins/migration-engine +1ms
download Using env var PRISMA_INTROSPECTION_ENGINE_BINARY for binary introspection-engine, which points to /home/kyle/starter/vendor-bins/introspection-engine +0ms
download Using env var PRISMA_FMT_BINARY for binary prisma-fmt, which points to /home/kyle/starter/vendor-bins/prisma-fmt +0ms
Prisma schema loaded from prisma/schema.prisma
prisma:download Using env var PRISMA_QUERY_ENGINE_BINARY for binary query-engine, which points to /home/kyle/starter/vendor-bins/query-engine +0ms
{ prismaClientDir: '/home/kyle/starter/node_modules/@prisma/client' }
prisma:download Using env var PRISMA_QUERY_ENGINE_BINARY for binary query-engine, which points to /home/kyle/starter/vendor-bins/query-engine +582ms
__dirname /home/kyle/starter/node_modules/@prisma/client/generator-build
/home/kyle/starter/node_modules/@prisma/client/generator-build
Error: Error:
TypeError: Cannot read property 'filter' of undefined
at getMappings (/home/kyle/starter/node_modules/@prisma/client/generator-build/index.js:75843:52)
at externalToInternalDmmf (/home/kyle/starter/node_modules/@prisma/client/generator-build/index.js:75839:15)
at getPrismaClientDMMF (/home/kyle/starter/node_modules/@prisma/client/generator-build/index.js:75873:10)
at buildClient (/home/kyle/starter/node_modules/@prisma/client/generator-build/index.js:73035:23)
at Object.generateClient (/home/kyle/starter/node_modules/@prisma/client/generator-build/index.js:73097:47)
at async LineStream.<anonymous> (/home/kyle/starter/node_modules/@prisma/client/generator-build/index.js:2802:26)
at Generate2.parse (/home/kyle/starter/node_modules/prisma/build/index.js:63971:17)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at async main (/home/kyle/starter/node_modules/prisma/build/index.js:100809:18)
Expected behavior
Client generation completes without error.
Prisma information
Default setup from Quickstart with Typescript
Environment & setup
- OS: Linux x86_64 (Centos 8)
- Database: Likely db-independent, but verified with SQLite
- Node.js version: v14.15.4
- Prisma version:
$ DEBUG="*" npx prisma -v
prisma:tryLoadEnv Environment variables not found at null +0ms
prisma:tryLoadEnv Environment variables loaded from ./prisma/.env +2ms
Environment variables loaded from prisma/.env
download Using env var PRISMA_QUERY_ENGINE_BINARY for binary query-engine, which points to /home/kyle/starter/vendor-bins/query-engine +0ms
download Using env var PRISMA_MIGRATION_ENGINE_BINARY for binary migration-engine, which points to /home/kyle/starter/vendor-bins/migration-engine +1ms
download Using env var PRISMA_INTROSPECTION_ENGINE_BINARY for binary introspection-engine, which points to /home/kyle/starter/vendor-bins/introspection-engine +0ms
download Using env var PRISMA_FMT_BINARY for binary prisma-fmt, which points to /home/kyle/starter/vendor-bins/prisma-fmt +0ms
prisma : 2.17.0
@prisma/client : 2.17.0
Current platform : rhel-openssl-1.1.x
Query Engine : query-engine 363f5a521d6b06543e53d134652a0037a3096d41 (at vendor-bins/query-engine, resolved by PRISMA_QUERY_ENGINE_BINARY)
Migration Engine : migration-engine-cli 363f5a521d6b06543e53d134652a0037a3096d41 (at vendor-bins/migration-engine, resolved by PRISMA_MIGRATION_ENGINE_BINARY)
Introspection Engine : introspection-core 363f5a521d6b06543e53d134652a0037a3096d41 (at vendor-bins/introspection-engine, resolved by PRISMA_INTROSPECTION_ENGINE_BINARY)
Format Binary : prisma-fmt 363f5a521d6b06543e53d134652a0037a3096d41 (at vendor-bins/prisma-fmt, resolved by PRISMA_FMT_BINARY)
Studio : 0.353.0
prisma:cli TypeError: Cannot read property 'length' of undefined
prisma:cli at /home/kyle/starter/node_modules/prisma/build/index.js:100832:77
prisma:cli at Array.find (<anonymous>)
prisma:cli at main (/home/kyle/starter/node_modules/prisma/build/index.js:100832:43) +0ms
Issue Analytics
- State:
- Created 3 years ago
- Comments:12 (6 by maintainers)
Top Results From Across the Web
Error message reference - Prisma
Prisma Client throws a PrismaClientUnknownRequestError exception if the query engine returns an error related to a request that does not have an error...
Read more >Prisma engines
Using custom engine libraries or binaries ... By default, all engine files are automatically downloaded into the node_modules/@prisma/engines folder when you ...
Read more >Deploying to a different OS - Prisma
The query engine is implemented in Rust and is used by Prisma in the form of executable binary files. The binary is downloaded...
Read more >Generating the client (Concepts) - Prisma
By default, Prisma Client is generated into the node_modules/.prisma/client folder, but you can specify a custom location. To generate and instantiate Prisma ......
Read more >Newest 'prisma-graphql' Questions - Stack Overflow
My use case is simple: There's users Users can create workspaces Users can delete workspaces User gets a role on each workspace (OWNER,...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Ultimately to support nix automatically, we can do something like this: https://github.com/fannheyward/coc-rust-analyzer/blob/3cca16908eebfb3e04003efe72c0274b9402ac14/src/downloader.ts#L16
Thanks @Jolg42, I agree it seems to be the same issue. I actually first ran into this on NixOS, but given that NixOS is not a high priority for Prisma I wanted to provide a simple repro on CentOS. Feel free to merge this and #5813 however works best for you