Closed pepijnve closed 1 year 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
~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
Thank you very much!
This PR applies the fix for D2 from #410 to all other diagram types.