Skip to content
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

Prisma ERD generator fails out of nothing suddenly. Worked before. #145

Closed
maakle opened this issue Oct 27, 2022 · 18 comments
Closed

Prisma ERD generator fails out of nothing suddenly. Worked before. #145

maakle opened this issue Oct 27, 2022 · 18 comments

Comments

@maakle
Copy link

maakle commented Oct 27, 2022

The generator fails with the following output:

mathiasklenk@passbase lucid % npx prisma generate
Environment variables loaded from .env
Prisma schema loaded from prisma/schema.prisma
data model written to /Users/mathiasklenk/Developer/lucid/prisma/debug/1-datamodel.json
applied @map to fields written to /Users/mathiasklenk/Developer/lucid/prisma/debug/2-datamodel-map-applied.json
mermaid written to /Users/mathiasklenk/Developer/lucid/prisma/debug/3-mermaid.mmd
mermaid command:  /Users/mathiasklenk/Developer/lucid/node_modules/.bin/mmdc -i /var/folders/qs/nv116z_51jv54p5lp4bx4vm80000gn/T/prisma-erd-JhnaHt/prisma.mmd -o /Users/mathiasklenk/Developer/lucid/prisma/ERD.svg -t forest -c /var/folders/qs/nv116z_51jv54p5lp4bx4vm80000gn/T/prisma-erd-JhnaHt/config.json
Error: 
✔ Generated Prisma Client (4.5.0 | library) to ./node_modules/@prisma/client in 159ms

Command failed: /Users/mathiasklenk/Developer/lucid/node_modules/.bin/mmdc -i /var/folders/qs/nv116z_51jv54p5lp4bx4vm80000gn/T/prisma-erd-JhnaHt/prisma.mmd -o /Users/mathiasklenk/Developer/lucid/prisma/ERD.svg -t forest -c /var/folders/qs/nv116z_51jv54p5lp4bx4vm80000gn/T/prisma-erd-JhnaHt/config.json

I have it setup like this in my schema.prisma file:

generator erd {
  provider = "prisma-erd-generator"
  output   = "./ERD.svg"
  erdDebug = true
}

I'm using "prisma-erd-generator": "^1.2.1" and "@mermaid-js/mermaid-cli": "^9.1.7" in my package.json. Is this a known bug or anything I am doing wrong?

@jferrettiboke
Copy link

Yeah. I can confirm prisma-erd-generator breaks with Prisma 4.5.0.

@keonik
Copy link
Owner

keonik commented Oct 31, 2022

Hoping the latest release updating dependencies fixed it 🤞🏼 checking now. Just released a version with 4.5 prisma

@keonik
Copy link
Owner

keonik commented Oct 31, 2022

Seemed to work on my end for a few simple cases. @mathiasklenk @jferrettiboke still getting the issue?

@jferrettiboke
Copy link

@keonik Unfortunately, it doesn't work. I'm still getting the same issue. These are my dependencies.

{
  ...
  "dependencies": {
    ...
    "@prisma/client": "^4.5.0"
  },
  "devDependencies": {
    ...
    "@mermaid-js/mermaid-cli": "^9.1.7",
    "prisma": "^4.5.0",
    "prisma-erd-generator": "^1.2.2"
  }
}

Could it be related with mmdc instead? The error says that the command failed.

@magnokf
Copy link

magnokf commented Nov 2, 2022

Still without solution

npx prisma generate
Environment variables loaded from .env
Prisma schema loaded from prisma/schema.prisma

Command failed: /home/magnokf/rocketseat/ignite/nlw/copa/server/node_modules/.bin/mmdc -i /tmp/prisma-erd-rxQgJh/prisma.mmd -o /home/magnokf/rocketseat/ignite/nlw/copa/server/prisma/ERD.svg -t forest -c /tmp/prisma-erd-rxQgJh/config.json

@keonik
Copy link
Owner

keonik commented Nov 2, 2022

Okay next guess is to go through the OS and node versions to see if you are one of the current issues around mmdc and mermaid with Windows

@maakle
Copy link
Author

maakle commented Nov 3, 2022

It's weird, the last few days it worked again. So it's kinda a bit unpredictable I must say. What fixes the issue temporarily was to completely remove the library and also @mermaid-js/mermaid-cli and then installing it again. Don't know if that helps though!

@johncblandii
Copy link

I got the same mmdc error and I resolved it by deleting node_modules for a fresh install.

@jferrettiboke
Copy link

jferrettiboke commented Nov 3, 2022

@johncblandii That didn't work for me. I tried that multiple times without any luck. The error seems to be consistent across environments (development/localhost, production/localhost, preview/Vercel, and production/Vercel).

@keonik BTW, I don't know if this could be related or not, but I have a monorepo setup. Mentioning this just in case.

@pmdpaula
Copy link

pmdpaula commented Nov 4, 2022

I've tried everything above and what worked for me was:
sudo apt-get install libxkbcommon-x11-0

I'm using Win10 WSL2 Ubuntu22.02
Node v18.12.0

@itaitan
Copy link

itaitan commented Nov 6, 2022

I got the same problem,
i don`t what to do...
no resolution so far

@keonik
Copy link
Owner

keonik commented Nov 9, 2022

Keep sharing OS and Node versions. Thus far it’s been mermaid issues with a few OS’s. As a fallback I believe running a .md file as the output can bypass a script related to this issue.

@keonik
Copy link
Owner

keonik commented Nov 9, 2022

Related to #123

@JNotelddim
Copy link

First, sorry for all the duplicate "JNotelddim added a commit that referenced this issue" items 🙈
I was force-pushing that branch after rebasing and didn't realize it'd affect this Issue thread.

Anyways, that aside:

Environment

I'm on MacOS Monterey (v12.4) with an M1 chip.

I'm working with [email protected], and [email protected] (as a dev dependency), node version: 18.12.0

Problem

When I try to prisma generate, I'm seeing this error:

#0 1.417 $ prisma generate                                                                                                                                                     
#0 17.29 Environment variables loaded from .env                                                                                                                                
#0 17.31 Prisma schema loaded from prisma/schema.prisma                                                                                                                        
#0 37.05 Error: 
#0 37.05 ✔ Generated Prisma Client (4.5.0 | library) to ./node_modules/@prisma/client in 459ms
#0 37.05 
#0 37.05 Command failed: /usr/src/app/node_modules/.bin/mmdc -i /tmp/prisma-erd-MGInAL/prisma.mmd -o /usr/src/app/prisma/ERD.svg -t forest -c /tmp/prisma-erd-MGInAL/config.json
#0 37.05 
#0 37.05 
#0 37.13 error Command failed with exit code 1.
#0 37.14 info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

(looks like the same mmdc issue that others are mentioning)

If i delete node_modules and reinstall, it does succeed -- however,
When I try to build this app with docker, even if I add steps in my dockerfile to manually clear the node_modules and reinstall the packages, I still see the error.


So it is manageable for local development, but I'm needing a solution for building a docker image of my app.
I'm thinking of trying adding a yarn remove prisma-erd-generator step in the Dockerfile so that the image would be built without the package, but there's still an issue of how to remove the generator erd { provider = "prisma-erd-generator" } section of the schema.prisma.

Anyways if anyone has a solution feel free to let me know :)

@keonik
Copy link
Owner

keonik commented Nov 10, 2022

First, sorry for all the duplicate "JNotelddim added a commit that referenced this issue" items 🙈 I was force-pushing that branch after rebasing and didn't realize it'd affect this Issue thread.

Anyways, that aside:

Environment

I'm on MacOS Monterey (v12.4) with an M1 chip.

I'm working with [email protected], and [email protected] (as a dev dependency), node version: 18.12.0

Problem

When I try to prisma generate, I'm seeing this error:

#0 1.417 $ prisma generate                                                                                                                                                     
#0 17.29 Environment variables loaded from .env                                                                                                                                
#0 17.31 Prisma schema loaded from prisma/schema.prisma                                                                                                                        
#0 37.05 Error: 
#0 37.05 ✔ Generated Prisma Client (4.5.0 | library) to ./node_modules/@prisma/client in 459ms
#0 37.05 
#0 37.05 Command failed: /usr/src/app/node_modules/.bin/mmdc -i /tmp/prisma-erd-MGInAL/prisma.mmd -o /usr/src/app/prisma/ERD.svg -t forest -c /tmp/prisma-erd-MGInAL/config.json
#0 37.05 
#0 37.05 
#0 37.13 error Command failed with exit code 1.
#0 37.14 info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

(looks like the same mmdc issue that others are mentioning)

If i delete node_modules and reinstall, it does succeed -- however, When I try to build this app with docker, even if I add steps in my dockerfile to manually clear the node_modules and reinstall the packages, I still see the error.

So it is manageable for local development, but I'm needing a solution for building a docker image of my app. I'm thinking of trying adding a yarn remove prisma-erd-generator step in the Dockerfile so that the image would be built without the package, but there's still an issue of how to remove the generator erd { provider = "prisma-erd-generator" } section of the schema.prisma.

Anyways if anyone has a solution feel free to let me know :)

Others use the disable flag to skip the ERD in docker.

@keonik
Copy link
Owner

keonik commented Nov 10, 2022

https://github.com/keonik/prisma-erd-generator#disabled

@JNotelddim
Copy link

Others use the disable flag to skip the ERD in docker.

Ahh beautiful, thanks 🙏

@keonik
Copy link
Owner

keonik commented Mar 21, 2023

It's weird, the last few days it worked again. So it's kinda a bit unpredictable I must say. What fixes the issue temporarily was to completely remove the library and also @mermaid-js/mermaid-cli and then installing it again. Don't know if that helps though!

Closing after finding this out. I believe the issue was an upgrade in mermaid going from v8 to v9. The alpha release which is v.1.3.0 of this repository is updated to version 10. Give it a try and let me know if this issue persists.

@keonik keonik closed this as completed Mar 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants