asciidoctor / asciidoctorj-diagram

AsciidoctorJ Diagram bundles the Asciidoctor Diagram RubyGem (asciidoctor-diagram) so it can be loaded into the JVM using JRuby.
Apache License 2.0
10 stars 6 forks source link

Missing `dot` executable does not fail build #18

Open ginkel opened 3 years ago

ginkel commented 3 years ago

Hi there,

when using asciidoctorj-diagram along with asciidoctor-maven-plugin to generate inline PlantUML diagrams from within the Maven build, a missing dot executable does not cause the build to fail, but the images are silently not generated. The following log is emitted to STDOUT:

[INFO] asciidoctor: DEBUG: Finding 'dot' in attributes
[INFO] asciidoctor: DEBUG: Finding 'dot' in environment
java.io.IOException: Cannot run program "/opt/local/bin/dot": error=2, No such file or directory
        at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1142)
        at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1073)
        at java.base/java.lang.Runtime.exec(Runtime.java:590)
        at net.sourceforge.plantuml.cucadiagram.dot.ProcessRunner$MainThread.startThreads(ProcessRunner.java:158)
        at net.sourceforge.plantuml.cucadiagram.dot.ProcessRunner$MainThread.runJob(ProcessRunner.java:118)
        at net.sourceforge.plantuml.api.TimeoutExecutor$MyThread.run(TimeoutExecutor.java:74)
Caused by: java.io.IOException: error=2, No such file or directory
        at java.base/java.lang.ProcessImpl.forkAndExec(Native Method)
        at java.base/java.lang.ProcessImpl.<init>(ProcessImpl.java:313)
        at java.base/java.lang.ProcessImpl.start(ProcessImpl.java:244)
        at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1109)
        ... 5 more
java.io.IOException: Cannot run program "/opt/local/bin/dot": error=2, No such file or directory
        at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1142)
        at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1073)
        at java.base/java.lang.Runtime.exec(Runtime.java:590)
        at net.sourceforge.plantuml.cucadiagram.dot.ProcessRunner$MainThread.startThreads(ProcessRunner.java:158)
        at net.sourceforge.plantuml.cucadiagram.dot.ProcessRunner$MainThread.runJob(ProcessRunner.java:118)
        at net.sourceforge.plantuml.api.TimeoutExecutor$MyThread.run(TimeoutExecutor.java:74)
Caused by: java.io.IOException: error=2, No such file or directory
        at java.base/java.lang.ProcessImpl.forkAndExec(Native Method)
        at java.base/java.lang.ProcessImpl.<init>(ProcessImpl.java:313)
        at java.base/java.lang.ProcessImpl.start(ProcessImpl.java:244)
        at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1109)
        ... 5 more

Unfortunately, I have not been able to identify a means of getting the build to fail in this situation using asciidoctor-maven-plugin's logHandler directive, as the error seems to be emitted via e.printStackTrace() and no error is logged via the regular logging mechanism.

Any idea how to fail the build in this situation is much appreciated!

Thanks, ThIlo

robertpanzer commented 3 years ago

Could you please provide a simple example to reproduce?

rmannibucau commented 1 year ago

+1, there are actually two issues with plantuml integration:

  1. It uses the assumption graphviz is installed locally (and does not use a js/java implementation so it is more setup to do)
  2. It silently fails (previous error does not fail the build)

Would be great to work out of the box (can be tested with maven:3.8.6-amazoncorretto-17 docker image).

robertpanzer commented 1 year ago

To let the build fail asciidoctor-diagram would need to use Asciidoctor's logging facility. But that's sth that would need to be implemented in asciidoctor/asciidoctor-diagram.

Same for the pure java implementation of graphviz, it might be added to asciidoctor/asciidoctor-diagram, or provided as a dedicated extension, but there's not much to do about this in this repo.