Can't render component diagram with PlantUML in IntelliJ
Asked Answered
P

7

75

I am trying to create a component diagram using the PlantUML plugin for IntelliJ. I have installed the plugin and worked with it before. However, when I try to render a component diagram, I get an error:

Cannot find Graphviz

enter image description here

I've also checked with other diagrams and a sequence diagram is still working just fine.

enter image description here

What is the problem here?

Philanthropist answered 29/1, 2019 at 4:42 Comment(2)
There is related issue on plugin issue tracker: github.com/esteinberg/plantuml4idea/issues/200Unregenerate
it looks exactly the same but I dont see how he solve the problem. Maybe I need to reinstall Grapgviz? how can I do it?Philanthropist
P
92

Option 1.

On a mac using Intellij, if Intellij cannot find graphviz, testdot doesn't work and graphviz was installed with brew install graphviz:

  1. In Intellij, click the wrench icon on the far right of the menu panel that contains the plantuml view and editor arrangement.
  2. Click 'Open settings'
  3. For 'Graphviz dot executable' add /opt/homebrew/bin/dot.
  4. Click OK and restart Intellij.

This fixes the issue for me.

You can check first that you really are missing the /opt/local/bin/dot (or whatever path you're shown is broken) and the /opt/homebrew/bin/dot exists, but likely the reason is that brew put dot under its own path.

Option 2.

Found myself on this same thread while using Windows 11 having a similar issue. The puml and plantuml codeblocks weren't displaying the diagram in a markdown file, only codeblock-ed text. What solved it for me:

  1. Go to Settings in Intellij,
  2. on the left menu, select Languages & Frameworks,
  3. and under it, select Markdown

Review the Markdown Extensions section. Install and enable PlantUML there. Same solution worked for Mermaid.

Physiological answered 9/2, 2022 at 15:8 Comment(6)
This works for PlantUML preview. Thanks! Any workaround to preview from Markdown as well?Exasperation
It looks like brew installs everything under /usr/local/bin so the path will be /usr/local/bin/dotDeflected
you are a saviourRaspings
To preview from the bundled Markdown, create a symlink from /usr/local/bin/dot to wherever homebrew installed your graphviz dot executable ( find out through which dot on your terminal )Sustentacular
this should be accepted answer if the op was a mac userMagnesium
In the Sonoma OS on my mac, the graphviz was installed here: /opt/homebrew/Cellar/graphviz/9.0.0/bin/dot When you paste it as a path, you must close the IntelliJ and open it again. You can also locale your file with brew list graphviz and then search for the executable dotTims
O
40

As mentioned here https://plantuml.com/graphviz-dot

Since version 1.2021.5, you can experimentally use PlantUML without installing Graphviz if you add !pragma layout smetana to your diagrams for the supported types. In that case, the "Smetana" engine is used instead of Graphviz

Therefore this worked for me;

@startuml
!pragma layout smetana
...
@enduml

I hope it helps!

Orfinger answered 1/4, 2022 at 0:54 Comment(0)
T
39

Sequence diagrams and activity diagrams work out of the box.

For other types of diagrams, you need to have Graphviz installed (version > 2.26.3).

  1. If you don't have Graphviz installed - just install it.
  2. If you have it installed but its version is improper - reinstall it.
  3. If you have it installed in proper version but location is other than default - point to that location. You can manage that either by specifying env variable GRAPHVIZ_DOT containing a path to Graphviz executable or pointing it out directly from IntelliJ's PlantUML plugin settings.

Here, you can read more on how to install Graphviz to get along with PlantUML.

Btw. I solved the same problem by simply typing sudo apt-get install graphviz in my console - maybe would work for you as well.

Thread answered 17/4, 2019 at 23:21 Comment(1)
I just solved this with brew install graphviz on my Mac and restarting IntelliJ. Thanks.Arnst
S
8

If you:

1.installed Graphviz

2.configured GRAPHVIZ_DOT env var to your dot.exe file (example D:\Program Files (x86)\Graphviz2.38\bin\dot.exe)

And you're still getting the same error: Cannot find Graphviz1. You probably need to configure the path to the dot.exe inside the Intelij settings.

Follow this tutorial to do so.

Sirrah answered 3/5, 2020 at 15:12 Comment(0)
C
3

In case it helps someone, these are the steps to resolve the same error (Can not find GraphViz...) from Eclipse editor.

  1. Install GraphViz on your system. Depending on your system, installation instructions are here: https://graphviz.org/download/ . For Mac (v11.6) users, it is as simple as brew install graphviz

  2. After installation is completed, add an environment variable: GRAPHVIZ_DOT to point to the path of the dot executable. On my machine, I added this:

    export GRAPHVIZ_DOT=/opt/homebrew/bin/dot

  3. Add path of the dot executable to Eclipse PlantUml preferences (Preferences --> Plant UML --> Path to the dot executable of Graph Viz). Screen shot given below:

enter image description here

Choe answered 19/10, 2021 at 7:27 Comment(0)
T
2
  1. First install graphviz

  2. Find dot executable and put it where IntelliJ can find it

    • Windows: Add the dot executable path in the environment variables path settings
    • Linux: find the location of dot using where dot and if it's not in the /opt/local/bin you can just create a symbolink link from lets say /usr/local/bin by running ln -s /usr/local/bin/dot /opt/local/bin/dot
  3. Restart IntelliJ

Thorin answered 4/5, 2022 at 7:10 Comment(0)
R
0

I had trouble too...the easiest way is to install the VsCode plugin 'Markdown Preview Enhanced' and then...magically...IntelliJ works fine too!!!

Recreate answered 7/7, 2021 at 15:25 Comment(1)
Installing yet another IDE (VsCode) to fix the one you already have is far for being the easiest way. Plugin most likely installs necessary dependencies as it supports importing .dot or .puml files to your Markdown - so there's nothing magicall about that.Thread

© 2022 - 2024 — McMap. All rights reserved.