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
442 stars 107 forks source link

Use stdin/out instead of TCP socket is broken on Windows #254

Closed habamax closed 4 years ago

habamax commented 4 years ago

TLDR; https://github.com/asciidoctor/asciidoctor-diagram/issues/254#issuecomment-571632957

After I have updated gem to v 2.0.0 asciidoctor-diagram doesn't work for me.

Win10, ruby 2.6, ruby 2.7 with current asciidoctor and asciidoctor-pdf.

More details: https://github.com/asciidoctor/asciidoctor-pdf/issues/1473

Test File

= Issue 1473: Plantuml? asciidoctor-diagram?
:imagesdir: images

== Introduction

[plantuml, hello_world, svg, width=70%]
....
skinparam monochrome true
skinparam shadowing true
skinparam dpi 300
skinparam backgroundcolor transparent
skinparam classarrowFontSize 8

!define table(x) class x << (T,#ede7aa) >>
!define view(x) class x << (V,lightblue) >>
!define f(n,t) {field}n <color:gray>: t</color>
!define string(n,size) {field}n <color:gray>: varchar(size)</color>

hide methods
hide stereotypes

table(DQI_ENGINE.DQI_SCHEDULE) {
    f(**sch_id**, **number**)
    ..
    string(dqi_plan_name, 500)
    string(sch_type, 20)
    f(priority, number)
    string(day_of_month, 100)
    string(day_of_week, 100)
    string(hour, 100)
    string(reference_date, 10)
    f(is_enabled, boolean)
}

....

command

asciidoctor-pdf -r asciidoctor-diagram issue-1473.adoc

output

NONE, it "works" and never stops.

With previous version 1.5.19 it works just fine.

habamax commented 4 years ago

Close for now as I am not sure what was the real reason.

pepijnve commented 4 years ago

I'm not sure what's getting stuck to be honest. I tried reproducing the problem here with the example you provided, but it seems to work just fine for me. (Tested on macOS, ruby 2.6.3p62, java 12.0.1+12, latest asciidoctor-pdf and asciidoctor-diagram)

habamax commented 4 years ago

I can reproduce it on win10, ruby2.7

https://github.com/asciidoctor/asciidoctor-pdf/issues/1473#issuecomment-571599092

pepijnve commented 4 years ago

Which Java runtime do you have installed? asciidoctor-diagram spawns a Java VM to run PlantUML so that could have an influence too.

habamax commented 4 years ago

Which Java runtime do you have installed?

java version "1.8.0_211" Java(TM) SE Runtime Environment (build 1.8.0_211-b12) Java HotSpot(TM) 64-Bit Server VM (build 25.211-b12, mixed mode)

habamax commented 4 years ago

I have tried again...

image

Waiting for 5 minutes before screenshot

pepijnve commented 4 years ago

Puzzling... I tried quickly with a 1.8 JRE and ruby 2.7; works fine on macOS. Unfortunately I'm afraid I don't have time right now to set up a Windows reproduction environment.

habamax commented 4 years ago

I have bisected it to

C:\Users\maksim.kim\projects\asciidoctor-diagram>git bisect good
39fda2bfbe3a3ea8baff7e803a380bc08047b800 is the first bad commit
commit 39fda2bfbe3a3ea8baff7e803a380bc08047b800
Author: Pepijn Van Eeckhoudt <pepijn@vaneeckhoudt.net>
Date:   Sun Nov 17 16:13:09 2019 +0100

    Use stdin/out instead of TCP socket

 lib/asciidoctor-diagram/util/java.rb        |   2 +-
 lib/asciidoctor-diagram/util/java_socket.rb |  16 +++++++---------
 lib/server-1.3.13.jar                       | Bin 21463 -> 0 bytes
 lib/server-1.3.14.jar                       | Bin 0 -> 22844 bytes
 4 files changed, 8 insertions(+), 10 deletions(-)
 delete mode 100644 lib/server-1.3.13.jar
 create mode 100644 lib/server-1.3.14.jar
habamax commented 4 years ago

For now I have just checkout the latest "good" commit and use it.

I have looked into the code and was not able to find out the real reason. Obviously CommandServer is involved but I have no expertise here/

habamax commented 4 years ago

@pepijnve could you give me intro on what is this change for and possible ways to solve it? Plus, do I have to have anything else apart jdk and ruby?

habamax commented 4 years ago

bundle exec rspec also hangs:

image

mojavelinux commented 4 years ago

Unfortunately I'm afraid I don't have time right now to set up a Windows reproduction environment.

Let's be careful with this so we don't give the wrong impression. We do test continuously only Windows through AppVeyor. So we don't mean that we aren't testing on Windows. But debugging takes extra effort and obviously a local environment takes time to set up. But there are virtual machines available for Windows (https://developer.microsoft.com/en-us/microsoft-edge/tools/vms/) to help with that. As a user, even if you already have Windows, it would be helpful if the user could describe to the devs how to reproduce using one of these virtual machines. That ensures debugging is as efficient as it can be.

mojavelinux commented 4 years ago

...so @habamax, could you test using the referenced virtual machine and give a list of steps you took to get it set up so that, if @pepijnve has time, he is able to quickly spin up that environment and get to where you are?

abelsromero commented 4 years ago

I have been able to reproduce it in a pretty clean Windows 10 Home installation I have. If you can point me where to look, I can do some extra research. For now I am just dropping everything here :% Here is the info of my environment:

$> systeminfo

Host Name:                 DESKTOP-KDG6FFN
OS Name:                   Microsoft Windows 10 Home
OS Version:                10.0.18363 N/A Build 18363
OS Manufacturer:           Microsoft Corporation
OS Configuration:          Standalone Workstation
OS Build Type:             Multiprocessor Free
Registered Owner:          ---------------------
Registered Organization:
Product ID:                00326-10000-00000-AA362
Original Install Date:     12/31/2019, 1:59:28 PM
System Boot Time:          1/7/2020, 11:56:23 PM
System Manufacturer:       Gigabyte Technology Co., Ltd.
System Model:              X570 AORUS ELITE
System Type:               x64-based PC
Processor(s):              1 Processor(s) Installed.
                           [01]: AMD64 Family 23 Model 113 Stepping 0 AuthenticAMD ~3593 Mhz
BIOS Version:              American Megatrends Inc. F11, 12/6/2019
Windows Directory:         C:\Windows
System Directory:          C:\Windows\system32
Boot Device:               \Device\HarddiskVolume2
System Locale:             en-us;English (United States)
Input Locale:              es;Spanish (Traditional Sort)
Time Zone:                 (UTC+01:00) Brussels, Copenhagen, Madrid, Paris
Total Physical Memory:     16,335 MB
Available Physical Memory: 11,231 MB
Virtual Memory: Max Size:  19,279 MB
Virtual Memory: Available: 10,919 MB
Virtual Memory: In Use:    8,360 MB
Page File Location(s):     C:\pagefile.sys
Domain:                    WORKGROUP
Logon Server:              N/A
Hotfix(s):                 7 Hotfix(s) Installed.
                           [01]: KB4533002
                           [02]: KB4513661
                           [03]: KB4516115
                           [04]: KB4517245
                           [05]: KB4521863
                           [06]: KB4524569
                           [07]: KB4530684
Network Card(s):           1 NIC(s) Installed.
                           [01]: Intel(R) I211 Gigabit Network Connection
                                 Connection Name: Ethernet
                                 DHCP Enabled:    Yes
                                 DHCP Server:     192.168.1.1
                                 IP address(es)
                                 [01]: 192.168.1.133
                                 [02]: fe80::681f:bc8d:dea4:9bb5
Hyper-V Requirements:      VM Monitor Mode Extensions: Yes
                           Virtualization Enabled In Firmware: No
                           Second Level Address Translation: Yes
                           Data Execution Prevention Available: Yes

I installed ruby, java & graphviz with chocolately

graphviz 2.38.0.20190211
ojdkbuild11 11.0.5.1
ruby 2.7.0.1

A simple asciidoctor example hangs, and also I cloned the repo and run these commands. Note that when running the tests, a lot fail and the Dita gets stuck also.

$> bundle
Fetching gem metadata from https://rubygems.org/..........
Fetching gem metadata from https://rubygems.org/.
Resolving dependencies...
Using rake 13.0.1
Using asciidoctor 2.0.10
Using asciidoctor-diagram 2.0.1.next1 from source at `.`
Using bundler 2.1.4
Fetching diff-lcs 1.3
Installing diff-lcs 1.3
Fetching rspec-support 3.9.2
Installing rspec-support 3.9.2
Fetching rspec-core 3.9.1
Installing rspec-core 3.9.1
Fetching rspec-expectations 3.9.0
Installing rspec-expectations 3.9.0
Fetching rspec-mocks 3.9.1
Installing rspec-mocks 3.9.1
Fetching rspec 3.9.0
Installing rspec 3.9.0
Bundle complete! 4 Gemfile dependencies, 10 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
$>rake test
C:/tools/ruby27/bin/ruby.exe -I'C:/tools/ruby27/lib/ruby/gems/2.7.0/gems/rspec-support-3.9.2/lib';'C:/tools/ruby27/lib/ruby/gems/2.7.0/gems/rspec-core-3.9.1/lib' 'C:/tools/ruby27/lib/ruby/gems/2.7.0/gems/rspec-core-3.9.1/exe/rspec' --pattern 'spec/**{,/*/**}/*_spec.rb'
Run options: exclude {:broken_on_windows=>true}

Asciidoctor::Diagram::BlockDiagBlockMacroProcessor
  should generate PNG images when format is set to 'png' (FAILED - 1)

Asciidoctor::Diagram::BlockDiagBlockProcessor
  should generate PNG images when format is set to 'png' (FAILED - 2)
  should generate SVG images when format is set to 'svg' (FAILED - 3)
  should generate PDF files when format is set to 'pdf' (FAILED - 4)
  should raise an error when when format is set to an invalid value
  should not regenerate images when source has not changed (FAILED - 5)
  should handle two block macros with the same source (FAILED - 6)
  should respect target attribute in block macros (FAILED - 7)

Asciidoctor::Diagram::BpmnBlockMacroProcessor
  should generate SVG images when format is set to 'svg' (FAILED - 8)
  should generate PNG images when format is set to 'png' (FAILED - 9)
  should generate PDF images when format is set to 'pdf' (FAILED - 10)

Asciidoctor::Diagram::DitaaBlockMacroProcessor

When I kill the process with Ctrl+C, this gets printed

RSpec is shutting down and will print the summary report... Interrupt again to force quit.
rake aborted!
Interrupt:

Tasks: TOP => test
(See full trace by running task with --trace)
Terminate batch job (Y/N)?   should generate PNG images when format is set to 'png' (FAILED - 11)

Failures:

  1) Asciidoctor::Diagram::BlockDiagBlockMacroProcessor should generate PNG images when format is set to 'png'
     Failure/Error: raise "Could not find the #{cmd_names.map { |c| "'#{c}'" }.join(', ')} executable in PATH; add it to the PATH or specify its location using the '#{attr_names[0]}' document attribute"

     RuntimeError:
       asciidoctor: FAILED: <stdin>: Failed to load AsciiDoc document - Could not find the 'blockdiag', 'blockdiag3' executable in PATH; add it to the PATH or specify its location using the 'blockdiag' document attribute
     # ./lib/asciidoctor-diagram/diagram_source.rb:91:in `find_command'
     # ./lib/asciidoctor-diagram/blockdiag/converter.rb:24:in `convert'
     # ./lib/asciidoctor-diagram/diagram_processor.rb:171:in `create_image_block'
     # ./lib/asciidoctor-diagram/diagram_processor.rb:87:in `process'
     # ./spec/test_helper.rb:90:in `load_asciidoc'
     # ./spec/blockdiag_spec.rb:23:in `block (2 levels) in <top (required)>'
     # ./spec/test_helper.rb:132:in `block (3 levels) in <top (required)>'
     # ./spec/test_helper.rb:131:in `chdir'
     # ./spec/test_helper.rb:131:in `block (2 levels) in <top (required)>'
     # ------------------
     # --- Caused by: ---
     # RuntimeError:
     #   Could not find the 'blockdiag', 'blockdiag3' executable in PATH; add it to the PATH or specify its location using the 'blockdiag' document attribute
     #   ./lib/asciidoctor-diagram/diagram_source.rb:91:in `find_command'

  2) Asciidoctor::Diagram::BlockDiagBlockProcessor should generate PNG images when format is set to 'png'
     Failure/Error: raise "Could not find the #{cmd_names.map { |c| "'#{c}'" }.join(', ')} executable in PATH; add it to the PATH or specify its location using the '#{attr_names[0]}' document attribute"

     RuntimeError:
       asciidoctor: FAILED: <stdin>: Failed to load AsciiDoc document - Could not find the 'blockdiag', 'blockdiag3' executable in PATH; add it to the PATH or specify its location using the 'blockdiag' document attribute
     # ./lib/asciidoctor-diagram/diagram_source.rb:91:in `find_command'
     # ./lib/asciidoctor-diagram/blockdiag/converter.rb:24:in `convert'
     # ./lib/asciidoctor-diagram/diagram_processor.rb:171:in `create_image_block'
     # ./lib/asciidoctor-diagram/diagram_processor.rb:87:in `process'
     # ./spec/test_helper.rb:90:in `load_asciidoc'
     # ./spec/blockdiag_spec.rb:55:in `block (2 levels) in <top (required)>'
     # ./spec/test_helper.rb:132:in `block (3 levels) in <top (required)>'
     # ./spec/test_helper.rb:131:in `chdir'
     # ./spec/test_helper.rb:131:in `block (2 levels) in <top (required)>'
     # ------------------
     # --- Caused by: ---
     # RuntimeError:
     #   Could not find the 'blockdiag', 'blockdiag3' executable in PATH; add it to the PATH or specify its location using the 'blockdiag' document attribute
     #   ./lib/asciidoctor-diagram/diagram_source.rb:91:in `find_command'

  3) Asciidoctor::Diagram::BlockDiagBlockProcessor should generate SVG images when format is set to 'svg'
     Failure/Error: raise "Could not find the #{cmd_names.map { |c| "'#{c}'" }.join(', ')} executable in PATH; add it to the PATH or specify its location using the '#{attr_names[0]}' document attribute"

     RuntimeError:
       asciidoctor: FAILED: <stdin>: Failed to load AsciiDoc document - Could not find the 'blockdiag', 'blockdiag3' executable in PATH; add it to the PATH or specify its location using the 'blockdiag' document attribute
     # ./lib/asciidoctor-diagram/diagram_source.rb:91:in `find_command'
     # ./lib/asciidoctor-diagram/blockdiag/converter.rb:24:in `convert'
     # ./lib/asciidoctor-diagram/diagram_processor.rb:171:in `create_image_block'
     # ./lib/asciidoctor-diagram/diagram_processor.rb:87:in `process'
     # ./spec/test_helper.rb:90:in `load_asciidoc'
     # ./spec/blockdiag_spec.rb:85:in `block (2 levels) in <top (required)>'
     # ./spec/test_helper.rb:132:in `block (3 levels) in <top (required)>'
     # ./spec/test_helper.rb:131:in `chdir'
     # ./spec/test_helper.rb:131:in `block (2 levels) in <top (required)>'
     # ------------------
     # --- Caused by: ---
     # RuntimeError:
     #   Could not find the 'blockdiag', 'blockdiag3' executable in PATH; add it to the PATH or specify its location using the 'blockdiag' document attribute
     #   ./lib/asciidoctor-diagram/diagram_source.rb:91:in `find_command'

  4) Asciidoctor::Diagram::BlockDiagBlockProcessor should generate PDF files when format is set to 'pdf'
     Failure/Error: raise "Could not find the #{cmd_names.map { |c| "'#{c}'" }.join(', ')} executable in PATH; add it to the PATH or specify its location using the '#{attr_names[0]}' document attribute"

     RuntimeError:
       asciidoctor: FAILED: <stdin>: Failed to load AsciiDoc document - Could not find the 'blockdiag', 'blockdiag3' executable in PATH; add it to the PATH or specify its location using the 'blockdiag' document attribute
     # ./lib/asciidoctor-diagram/diagram_source.rb:91:in `find_command'
     # ./lib/asciidoctor-diagram/blockdiag/converter.rb:24:in `convert'
     # ./lib/asciidoctor-diagram/diagram_processor.rb:171:in `create_image_block'
     # ./lib/asciidoctor-diagram/diagram_processor.rb:87:in `process'
     # ./spec/test_helper.rb:90:in `load_asciidoc'
     # ./spec/blockdiag_spec.rb:115:in `block (2 levels) in <top (required)>'
     # ./spec/test_helper.rb:132:in `block (3 levels) in <top (required)>'
     # ./spec/test_helper.rb:131:in `chdir'
     # ./spec/test_helper.rb:131:in `block (2 levels) in <top (required)>'
     # ------------------
     # --- Caused by: ---
     # RuntimeError:
     #   Could not find the 'blockdiag', 'blockdiag3' executable in PATH; add it to the PATH or specify its location using the 'blockdiag' document attribute
     #   ./lib/asciidoctor-diagram/diagram_source.rb:91:in `find_command'

  5) Asciidoctor::Diagram::BlockDiagBlockProcessor should not regenerate images when source has not changed
     Failure/Error: raise "Could not find the #{cmd_names.map { |c| "'#{c}'" }.join(', ')} executable in PATH; add it to the PATH or specify its location using the '#{attr_names[0]}' document attribute"

     RuntimeError:
       asciidoctor: FAILED: <stdin>: Failed to load AsciiDoc document - Could not find the 'blockdiag', 'blockdiag3' executable in PATH; add it to the PATH or specify its location using the 'blockdiag' document attribute
     # ./lib/asciidoctor-diagram/diagram_source.rb:91:in `find_command'
     # ./lib/asciidoctor-diagram/blockdiag/converter.rb:24:in `convert'
     # ./lib/asciidoctor-diagram/diagram_processor.rb:171:in `create_image_block'
     # ./lib/asciidoctor-diagram/diagram_processor.rb:87:in `process'
     # ./spec/test_helper.rb:90:in `load_asciidoc'
     # ./spec/blockdiag_spec.rb:164:in `block (2 levels) in <top (required)>'
     # ./spec/test_helper.rb:132:in `block (3 levels) in <top (required)>'
     # ./spec/test_helper.rb:131:in `chdir'
     # ./spec/test_helper.rb:131:in `block (2 levels) in <top (required)>'
     # ------------------
     # --- Caused by: ---
     # RuntimeError:
     #   Could not find the 'blockdiag', 'blockdiag3' executable in PATH; add it to the PATH or specify its location using the 'blockdiag' document attribute
     #   ./lib/asciidoctor-diagram/diagram_source.rb:91:in `find_command'

  6) Asciidoctor::Diagram::BlockDiagBlockProcessor should handle two block macros with the same source
     Failure/Error: raise "Could not find the #{cmd_names.map { |c| "'#{c}'" }.join(', ')} executable in PATH; add it to the PATH or specify its location using the '#{attr_names[0]}' document attribute"

     RuntimeError:
       asciidoctor: FAILED: <stdin>: Failed to load AsciiDoc document - Could not find the 'blockdiag', 'blockdiag3' executable in PATH; add it to the PATH or specify its location using the 'blockdiag' document attribute
     # ./lib/asciidoctor-diagram/diagram_source.rb:91:in `find_command'
     # ./lib/asciidoctor-diagram/blockdiag/converter.rb:24:in `convert'
     # ./lib/asciidoctor-diagram/diagram_processor.rb:171:in `create_image_block'
     # ./lib/asciidoctor-diagram/diagram_processor.rb:87:in `process'
     # ./spec/test_helper.rb:90:in `load_asciidoc'
     # ./spec/blockdiag_spec.rb:192:in `block (2 levels) in <top (required)>'
     # ./spec/test_helper.rb:132:in `block (3 levels) in <top (required)>'
     # ./spec/test_helper.rb:131:in `chdir'
     # ./spec/test_helper.rb:131:in `block (2 levels) in <top (required)>'
     # ------------------
     # --- Caused by: ---
     # RuntimeError:
     #   Could not find the 'blockdiag', 'blockdiag3' executable in PATH; add it to the PATH or specify its location using the 'blockdiag' document attribute
     #   ./lib/asciidoctor-diagram/diagram_source.rb:91:in `find_command'

  7) Asciidoctor::Diagram::BlockDiagBlockProcessor should respect target attribute in block macros
     Failure/Error: raise "Could not find the #{cmd_names.map { |c| "'#{c}'" }.join(', ')} executable in PATH; add it to the PATH or specify its location using the '#{attr_names[0]}' document attribute"

     RuntimeError:
       asciidoctor: FAILED: <stdin>: Failed to load AsciiDoc document - Could not find the 'blockdiag', 'blockdiag3' executable in PATH; add it to the PATH or specify its location using the 'blockdiag' document attribute
     # ./lib/asciidoctor-diagram/diagram_source.rb:91:in `find_command'
     # ./lib/asciidoctor-diagram/blockdiag/converter.rb:24:in `convert'
     # ./lib/asciidoctor-diagram/diagram_processor.rb:171:in `create_image_block'
     # ./lib/asciidoctor-diagram/diagram_processor.rb:87:in `process'
     # ./spec/test_helper.rb:90:in `load_asciidoc'
     # ./spec/blockdiag_spec.rb:209:in `block (2 levels) in <top (required)>'
     # ./spec/test_helper.rb:132:in `block (3 levels) in <top (required)>'
     # ./spec/test_helper.rb:131:in `chdir'
     # ./spec/test_helper.rb:131:in `block (2 levels) in <top (required)>'
     # ------------------
     # --- Caused by: ---
     # RuntimeError:
     #   Could not find the 'blockdiag', 'blockdiag3' executable in PATH; add it to the PATH or specify its location using the 'blockdiag' document attribute
     #   ./lib/asciidoctor-diagram/diagram_source.rb:91:in `find_command'

  8) Asciidoctor::Diagram::BpmnBlockMacroProcessor should generate SVG images when format is set to 'svg'
     Failure/Error: tool_name = File.basename(tool)

     TypeError:
       asciidoctor: FAILED: <stdin>: Failed to load AsciiDoc document - no implicit conversion of nil into String
     # ./lib/asciidoctor-diagram/util/cli_generator.rb:33:in `basename'
     # ./lib/asciidoctor-diagram/util/cli_generator.rb:33:in `generate_file'
     # ./lib/asciidoctor-diagram/bpmn/converter.rb:45:in `run_bpmnjs'
     # ./lib/asciidoctor-diagram/bpmn/converter.rb:39:in `convert'
     # ./lib/asciidoctor-diagram/diagram_processor.rb:171:in `create_image_block'
     # ./lib/asciidoctor-diagram/diagram_processor.rb:87:in `process'
     # ./spec/test_helper.rb:90:in `load_asciidoc'
     # ./spec/bpmn_spec.rb:19:in `block (2 levels) in <top (required)>'
     # ./spec/test_helper.rb:132:in `block (3 levels) in <top (required)>'
     # ./spec/test_helper.rb:131:in `chdir'
     # ./spec/test_helper.rb:131:in `block (2 levels) in <top (required)>'
     # ------------------
     # --- Caused by: ---
     # TypeError:
     #   no implicit conversion of nil into String
     #   ./lib/asciidoctor-diagram/util/cli_generator.rb:33:in `basename'

  9) Asciidoctor::Diagram::BpmnBlockMacroProcessor should generate PNG images when format is set to 'png'
     Failure/Error: tool_name = File.basename(tool)

     TypeError:
       asciidoctor: FAILED: <stdin>: Failed to load AsciiDoc document - no implicit conversion of nil into String
     # ./lib/asciidoctor-diagram/util/cli_generator.rb:33:in `basename'
     # ./lib/asciidoctor-diagram/util/cli_generator.rb:33:in `generate_file'
     # ./lib/asciidoctor-diagram/bpmn/converter.rb:45:in `run_bpmnjs'
     # ./lib/asciidoctor-diagram/bpmn/converter.rb:39:in `convert'
     # ./lib/asciidoctor-diagram/diagram_processor.rb:171:in `create_image_block'
     # ./lib/asciidoctor-diagram/diagram_processor.rb:87:in `process'
     # ./spec/test_helper.rb:90:in `load_asciidoc'
     # ./spec/bpmn_spec.rb:51:in `block (2 levels) in <top (required)>'
     # ./spec/test_helper.rb:132:in `block (3 levels) in <top (required)>'
     # ./spec/test_helper.rb:131:in `chdir'
     # ./spec/test_helper.rb:131:in `block (2 levels) in <top (required)>'
     # ------------------
     # --- Caused by: ---
     # TypeError:
     #   no implicit conversion of nil into String
     #   ./lib/asciidoctor-diagram/util/cli_generator.rb:33:in `basename'

  10) Asciidoctor::Diagram::BpmnBlockMacroProcessor should generate PDF images when format is set to 'pdf'
      Failure/Error: tool_name = File.basename(tool)

      TypeError:
        asciidoctor: FAILED: <stdin>: Failed to load AsciiDoc document - no implicit conversion of nil into String
      # ./lib/asciidoctor-diagram/util/cli_generator.rb:33:in `basename'
      # ./lib/asciidoctor-diagram/util/cli_generator.rb:33:in `generate_file'
      # ./lib/asciidoctor-diagram/bpmn/converter.rb:45:in `run_bpmnjs'
      # ./lib/asciidoctor-diagram/bpmn/converter.rb:39:in `convert'
      # ./lib/asciidoctor-diagram/diagram_processor.rb:171:in `create_image_block'
      # ./lib/asciidoctor-diagram/diagram_processor.rb:87:in `process'
      # ./spec/test_helper.rb:90:in `load_asciidoc'
      # ./spec/bpmn_spec.rb:83:in `block (2 levels) in <top (required)>'
      # ./spec/test_helper.rb:132:in `block (3 levels) in <top (required)>'
      # ./spec/test_helper.rb:131:in `chdir'
      # ./spec/test_helper.rb:131:in `block (2 levels) in <top (required)>'
      # ------------------
      # --- Caused by: ---
      # TypeError:
      #   no implicit conversion of nil into String
      #   ./lib/asciidoctor-diagram/util/cli_generator.rb:33:in `basename'

  11) Asciidoctor::Diagram::DitaaBlockMacroProcessor should generate PNG images when format is set to 'png'
      Failure/Error: status_line_parts = STATUS_LINE.match status_line

      ArgumentError:
        asciidoctor: FAILED: <stdin>: Failed to load AsciiDoc document - invalid byte sequence in US-ASCII
      # ./lib/asciidoctor-diagram/util/java.rb:55:in `match'
      # ./lib/asciidoctor-diagram/util/java.rb:55:in `parse_response'
      # ./lib/asciidoctor-diagram/util/java_socket.rb:64:in `send_request'
      # ./lib/asciidoctor-diagram/ditaa/converter.rb:72:in `convert'
      # ./lib/asciidoctor-diagram/diagram_processor.rb:171:in `create_image_block'
      # ./lib/asciidoctor-diagram/diagram_processor.rb:87:in `process'
      # ./spec/test_helper.rb:90:in `load_asciidoc'
      # ./spec/ditaa_spec.rb:28:in `block (2 levels) in <top (required)>'
      # ./spec/test_helper.rb:132:in `block (3 levels) in <top (required)>'
      # ./spec/test_helper.rb:131:in `chdir'
      # ./spec/test_helper.rb:131:in `block (2 levels) in <top (required)>'
      # ------------------
      # --- Caused by: ---
      # ArgumentError:
      #   invalid byte sequence in US-ASCII
      #   ./lib/asciidoctor-diagram/util/java.rb:55:in `match'

Finished in 8 minutes 7 seconds (files took 0.88689 seconds to load)
12 examples, 11 failures

Failed examples:

rspec ./spec/blockdiag_spec.rb:11 # Asciidoctor::Diagram::BlockDiagBlockMacroProcessor should generate PNG images when format is set to 'png'
rspec ./spec/blockdiag_spec.rb:42 # Asciidoctor::Diagram::BlockDiagBlockProcessor should generate PNG images when format is set to 'png'
rspec ./spec/blockdiag_spec.rb:72 # Asciidoctor::Diagram::BlockDiagBlockProcessor should generate SVG images when format is set to 'svg'
rspec ./spec/blockdiag_spec.rb:102 # Asciidoctor::Diagram::BlockDiagBlockProcessor should generate PDF files when format is set to 'pdf'
rspec ./spec/blockdiag_spec.rb:147 # Asciidoctor::Diagram::BlockDiagBlockProcessor should not regenerate images when source has not changed
rspec ./spec/blockdiag_spec.rb:179 # Asciidoctor::Diagram::BlockDiagBlockProcessor should handle two block macros with the same source
rspec ./spec/blockdiag_spec.rb:196 # Asciidoctor::Diagram::BlockDiagBlockProcessor should respect target attribute in block macros
rspec ./spec/bpmn_spec.rb:4 # Asciidoctor::Diagram::BpmnBlockMacroProcessor should generate SVG images when format is set to 'svg'
rspec ./spec/bpmn_spec.rb:36 # Asciidoctor::Diagram::BpmnBlockMacroProcessor should generate PNG images when format is set to 'png'
rspec ./spec/bpmn_spec.rb:68 # Asciidoctor::Diagram::BpmnBlockMacroProcessor should generate PDF images when format is set to 'pdf'
rspec ./spec/ditaa_spec.rb:4 # Asciidoctor::Diagram::DitaaBlockMacroProcessor should generate PNG images when format is set to 'png'

Traceback (most recent call last):
        2: from C:/tools/ruby27/lib/ruby/gems/2.7.0/gems/rspec-core-3.9.1/exe/rspec:4:in `<main>'
        1: from C:/tools/ruby27/lib/ruby/gems/2.7.0/gems/rspec-core-3.9.1/lib/rspec/core/runner.rb:46:in `invoke'
C:/tools/ruby27/lib/ruby/gems/2.7.0/gems/rspec-core-3.9.1/lib/rspec/core/runner.rb:46:in `exit': exit (SystemExit)
        2: from C:/Users/----/github/asciidoctor-diagram/lib/asciidoctor-diagram/util/java_socket.rb:51:in `block in instance'
        1: from C:/Users/----/github/asciidoctor-diagram/lib/asciidoctor-diagram/util/java_socket.rb:29:in `shutdown'
C:/Users/----/github/asciidoctor-diagram/lib/asciidoctor-diagram/util/java_socket.rb:29:in `kill': No such process (Errno::ESRCH)
abelsromero commented 4 years ago

I replicated the installation in another machine I have with Windows 8.1 and the issue also happens with latest versions of asciidocotr & asciidoctor-diagram.

Downgrading to previous versions works with this small test doc

= diagram tst

== section

[plantuml]
....
class BlockProcessor
class PlantUmlBlock
BlockProcessor <|-- PlantUmlBlock
....

Tomorrow I'll try and check the commit mentioned

mojavelinux commented 4 years ago

It looks like the last successful build on AppVeyor was 7 months ago. I hadn't realized that wasn't passing.

@abelsromero Is the error AppVeyor is reporting the same? If not, perhaps we should see whether we can get AppVeyor to use a different version of Windows. It's important that AppVeyor reflect the experience of Windows users.

abelsromero commented 4 years ago

Is the error AppVeyor is reporting the same?

Appveyour builds fail during pre-requisites intallations last on during npm install -g wavedrom-cli and previous ones cinst graphviz.portable. So the build is not even getting to the error.

perhaps we should see whether we can get AppVeyor to use a different version of Windows.

According to documentation Github actions is Windows Server 2016 o 2019, same as Appveyour. We can try and see.

habamax commented 4 years ago

...so @habamax, could you test using the referenced virtual machine and give a list of steps you took to get it set up so that, if @pepijnve has time, he is able to quickly spin up that environment and get to where you are?

Is it still needed? If so, what type of vm should I use?

mojavelinux commented 4 years ago

I've linked to it: https://developer.microsoft.com/en-us/microsoft-edge/tools/vms/

The reason the virtual machine is useful is because we can all test on exactly the same machine. You can use it to create step-by-step instructions to get everyone on the same page.

Though, from the sound of it, we are seeing this same issue on almost any Windows machine, so there probably isn't much in the way of instructions other than install Ruby, install git, clone the project, and run the test suite.

habamax commented 4 years ago

I've linked to it: https://developer.microsoft.com/en-us/microsoft-edge/tools/vms/

From the link I should select type of the vm image

Or it doesn't matter?

The reason the virtual machine is useful is because we can all test on exactly the same machine. You can use it to create step-by-step instructions to get everyone on the same page.

Indeed. Just to clarify, this vm runs on your local machine, right? Not in the cloud everyone can login to and see the same as I do?

Though, from the sound of it, we are seeing this same issue on almost any Windows machine, so there probably isn't much in the way of instructions other than install Ruby, install git, clone the project, and run the test suite.

Yes, that was my thought when I asked about whether it is still needed for this issue.

mojavelinux commented 4 years ago

VirtualBox is the most portable choice in my experience.

Just to clarify, this vm runs on your local machine, right?

That's correct. Think of it like Docker, but for Windows.

pepijnve commented 4 years ago

Looks like I broke Windows support with my TCP -> stdin/stdout change 😱 It's not entirely surprising that this works a bit different on Unixes vs Windows. I'll have a look and see where things get stuck.

We'll have to get Windows CI builds back up and running to avoid this kind of regression. Appveyor has been quite a pain to use, so I haven't been paying much attention to it. My bad. I noticed yesterday that Travis has some basic Windows support these days as well; perhaps it's worth considering switching everything over to Travis?

mojavelinux commented 4 years ago

perhaps it's worth considering switching everything over to Travis?

Absolutely. Or GitHub Actions. AppVeyor is not the only game in town anymore. https://github.com/features/actions

pepijnve commented 4 years ago

One missing character 🤦‍♂

@habamax since you were asking how this stuff worked:

PlantUML is written in Java. Launching a new instance of PlantUML for every individual diagram is prohibitively slow when dealing with large documents with many diagrams. The JVM just takes too long to start up. To speed this up we need a way to launch the JVM once and reuse it.

One solution for that would be to launch the PlantUML server, but that would only work for PlantUML, not for other Java-based tools like Ditaa. So instead of doing that I created my own mini server (see https://github.com/asciidoctor/asciidoctor-diagram-java). It's essentially a naive little HTTP server that can render PlantUML and Ditaa diagrams.

The older versions of this server bound a TCP socket, printed the listening port on stdout and then waited for incoming requests on that port. Asciidoctor-diagram read the TCP port from stdout and then connected to the service on the loopback interface. At one point I realised that's needlessly complicated. The service is spawned as a subprocess so we can simply communicate with it over stdin/stdout instead. Unfortunately I forgot that on Windows IO does EOL <-> CRLF conversion by default. Since we're talking HTTP over stdin/out and expect binary data (PNGs) as response that definitely needs to be turned off.

pepijnve commented 4 years ago

@habamax could you check if commit eee4c50 fixes the problem for you?

habamax commented 4 years ago

I have pulled the latest and it works!

(I have deleted asciidoctor-diagram gem just to be sure I use the right one)

Thank you!

pepijnve commented 4 years ago

Excellent. I just released v2.0.1 with just this fix.

habamax commented 4 years ago

have tested new gem -- looks good!

abelsromero commented 4 years ago

👍 also validated in both my machinges, win 8.1 & 10.

mojavelinux commented 4 years ago

Thanks @pepijnve! You're a :star:!

RandomCore commented 4 years ago

I just stumbled across this issue and may (still) have the same:

$ cat example.adoc
= Some title

A diagram with plan-uml:

[.text-center]
[subs="attributes"]
[plantuml,"structure",png]
....
@startsalt
{
   { T
    + <&folder> /
    ++ <&folder> usr
    +++ <&folder> share
   }
}
....

End.
$ asciidoctor -r asciidoctor-diagram -o example.html example.adoc

This hangs. I use Windows 10 and cygwin. Some version info:

$ ruby --version
ruby 2.6.4p104 (2019-08-28 revision 67798) [x86_64-cygwin]
$ bundle
Using Ascii85 1.0.3
Using public_suffix 4.0.3
Using addressable 2.7.0
Using afm 0.2.2
Using asciidoctor 2.0.10
Using asciidoctor-diagram 2.0.1
Using concurrent-ruby 1.1.5
Using pdf-core 0.7.0
Using ttfunk 1.5.1
Using prawn 2.2.2
Using prawn-icon 2.5.0
Using css_parser 1.7.1
Using prawn-svg 0.30.0
Using prawn-table 0.2.2
Using hashery 2.1.2
Using ruby-rc4 0.1.5
Using pdf-reader 2.4.0
Using prawn-templates 0.1.2
Using safe_yaml 1.0.5
Using thread_safe 0.3.6
Using polyglot 0.3.5
Using treetop 1.5.3
Using asciidoctor-pdf 1.5.0.rc.2
Using bundler 1.17.2
Using rouge 3.15.0

Any ideas?

pepijnve commented 4 years ago

@RandomCore could this be related to #268?

RandomCore commented 4 years ago

@RandomCore could this be related to #268?

I don't think so. I start with the above example.adoc in an otherwise empty directory and it hangs on the first asciidoctor start. Which implies, there is no graphic generated.

Can I do something else, to help debug this?

pepijnve commented 4 years ago

Ok, please open a new issue in that case. Could look up which version of cygwin you're using. As #268 showed differences in the cygwin runtime library can also cause different behaviour at the application level.