asciidoctor / asciidoctor-diagram

:left_right_arrow: Asciidoctor diagram extension, with support for AsciiToSVG, BlockDiag (BlockDiag, SeqDiag, ActDiag, NwDiag), Ditaa, Erd, GraphViz, Mermaid, Msc, PlantUML, Shaape, SvgBob, Syntrax, UMLet, Vega, Vega-Lite and WaveDrom.
http://asciidoctor.org
MIT License
439 stars 107 forks source link

PNG rendering fails with graphviz on Windows #51

Closed domgold closed 9 years ago

domgold commented 9 years ago

When I render the following block:

[graphviz,"test",svg]
----
graph G {
  clusterC -- clusterB
}
----

I get the following error message: (RuntimeError) Invalid PNG signature

I am using the basic maven setup from the maven examples (asciidoctor-diagram-example) on a french Windows 7 Pro.

I patched the file 'png.rb' which causes this error by returning a size by default. With this patched version the png file gets created but is corrupted.

I suspect this being an encoding issue UTF-8 vs ISO.

(Btw, I also tried generating the png on my command line with the exact same parameters and it works.)

Below the complete error output.

[INFO] --- asciidoctor-maven-plugin:1.5.0:process-asciidoc (generate-html-doc) @
 asciidoctor-diagram-example ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.248 s
[INFO] Finished at: 2014-11-06T13:30:58+01:00
[INFO] Final Memory: 12M/30M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.asciidoctor:asciidoctor-maven-plugin:1.5.0:pr
ocess-asciidoc (generate-html-doc) on project asciidoctor-diagram-example: Execu
tion generate-html-doc of goal org.asciidoctor:asciidoctor-maven-plugin:1.5.0:pr
ocess-asciidoc failed: (RuntimeError) Invalid PNG signature -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e swit
ch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please rea
d the following articles:
pepijnve commented 9 years ago

I think you're right that this is an encoding issue. As part of #48 I'm reworking the Ruby/Java interfacing code in a way that should make things more robust. That will probably also fix this. I'll make sure to test my changes on Windows as well. Unfortunately Windows isn't supported on Travis yet so it's not covered by the automated test runs.

pepijnve commented 9 years ago

My previous comment was actually completely incorrect since graphviz is invoked directly; not through the Java bridge. The code in cli_generator.rb is reading the generated file using mode 'r' which does newline processing. Switching to mode 'rb' resolves the issue.

pepijnve commented 9 years ago

I've been able to reproduce this and confirmed it is fixed in 1.3.0.preview.3.

mojavelinux commented 9 years ago

:+1:

Btw, I just found out that appveyor.com offers CI builds on Windows machines. You could look into getting the build setup there so that we can catch these issues early on and keep them at bay.

pepijnve commented 9 years ago

I'll see what I can do for the appveyor builds. Getting basic tests up and running should be feasible. I think I'll skip shaape and blockdiag initially though. Those two have a bunch of additional dependencies that are going to be a pain to get set up on windows.

pepijnve commented 9 years ago

Basic setup for appveyor is done. I still need to fix a ruby gems SSL certificate issue and get graphviz installed, but that should be too much of a problem.

mojavelinux commented 9 years ago

Excellent! I'll be diving into appveyor config for core, so I'll share any tips I discover.

pepijnve commented 9 years ago

Almost there. Biggest hurdle was that the rubygems version is out of data which causes SSL certificate failures when using https://rubygems.org as source. I tried updating ruby gems but then gem install seemed to hang. I'm using http://rubygems.org as source now when the build runs on appveyor.

pepijnve commented 9 years ago

@mojavelinux alright, the builds are up and running and the test are passing. The setup in asciidoctor-diagrams apveyor.yml is the only one I was able to get working. Here's some notes on the work I did

Beyond that the setup is almost identical to the travis one.

mojavelinux commented 9 years ago

Awesome!!! :beers:

Got a link to the AppVeyor build results?

(Btw, we should probably get an Asciidoctor organization setup on AppVeyor so we can share permissions. I'll look into it when I get the build setup for Asciidoctor core).

pepijnve commented 9 years ago

https://ci.appveyor.com/project/pepijnve/asciidoctor-diagram They're referenced from the README via status badges.

mojavelinux commented 9 years ago

Nice!

mojavelinux commented 9 years ago

@pepijnve would you be willing to switch the AppVeyor build to point to the asciidoctor account?

Here are the relevant URLs:

It's setup exactly the same, so you should just be able to change those two values and it will just work. You can control the webhook URL in the settings tab of the repo. The badge URL goes in the README.

mojavelinux commented 9 years ago

Here's the project URL on AppVeyor.

https://ci.appveyor.com/project/asciidoctor/asciidoctor-diagram

I'll send you the credentials for the asciidoctor account on AppVeyor.

pepijnve commented 9 years ago

README updated and verified that the web hook is working correctly.

mojavelinux commented 9 years ago

Most excellent!

Asciidoctor is on AppVeyor now in full force!