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
431 stars 106 forks source link

#437 Use diagram source base dir as working directory for all exec'd processes #438

Closed pepijnve closed 9 months ago

pepijnve commented 9 months ago

This PR applies the fix for D2 from #410 to all other diagram types.

singh-sp commented 9 months ago

This change may not be sufficient for fixing all related scenarios.

Example:

From D2 docs(https://d2lang.com/tour/imports/#imports-are-relative-to-that-file):

# Imports are relative to that file
Not to the executing path.

Consider that your working directory is /Users/You/dev. Your D2 files:

/Users/you/dev/d2-stuff/x.d2
y: @../y.d2
The above import will search directory /Users/you/dev/ for y.d2, not /Users/You.

Therefore, currently, a D2 file cannot be rendered if it has an import statement.

Sample error:

asciidoctor: ERROR: my-app.adoc: line 27: Failed to generate image: d2 failed: err: failed to compile: /var/folders/n7/wym_03hs1zd_td_w2c4hp43m0000gp/T/d220230915-12470-mlbbhi.d2:5:10: failed to import "/var/folders/n7/wym_03hs1zd_td_w2c4hp43m0000gp/T/components.d2": open /var/folders/n7/wym_03hs1zd_td_w2c4hp43m0000gp/T/components.d2: no such file or directory
err: /var/folders/n7/wym_03hs1zd_td_w2c4hp43m0000gp/T/d220230915-12470-mlbbhi.d2:6:8: failed to import "/var/folders/n7/wym_03hs1zd_td_w2c4hp43m0000gp/T/components.d2": open /var/folders/n7/wym_03hs1zd_td_w2c4hp43m0000gp/T/components.d2: no such file or directory

For testing, you can use D2 code from here: https://d2lang.com/tour/imports/#2-spread-import

pepijnve commented 9 months ago

~Could you log a distinct issue for this. This PR is not the appropriate place since it doesn't change anything wrt D2.~ Never mind. #439

singh-sp commented 9 months ago

Thank you very much!