Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Imported classes with relative file paths fail #2059

Closed
dzoeteman opened this issue Aug 14, 2024 · 1 comment · Fixed by #2066
Closed

Imported classes with relative file paths fail #2059

dzoeteman opened this issue Aug 14, 2024 · 1 comment · Fixed by #2066

Comments

@dzoeteman
Copy link

#1924 (0.6.6) changed relative file paths to be relative to the file instead of working directory of CLI execution.
While I support this change, there is one issue introduced, where relative paths in classes do not work if they're imported.

This example I hope explains the use case. Assume you have a directory structure as such:

my-diagrams/
├─ diagrams/
│  ├─ subset/
│  │  ├─ test.d2
│  ├─ icons/
│  │  ├─ test.svg
│  ├─ models.d2

With models.d2:

classes: {
  myclass: {
    shape: image
    icon: ./diagrams/icons/test.svg
    width: 100
    height: 100
  }
}

And test.d2:

direction: right

...@../models

myobj {
  class: myclass
}

Before, I could make this work by executing the following, with the working directory being my-diagrams:
d2 diagrams/subset/test.d2 output.svg

However, now I get the following error if I do that:

err: failed to bundle ./diagrams/icons/test.svg: open /Users/myuser/workspace/my-diagrams/diagrams/subset/diagrams/icons/test.svg: no such file or directory
err: failed to compile diagrams/subset/test.d2: failed to bundle local images: [./diagrams/icons/test.svg]

Am I missing a way where this could still work, or is this something that might require a fix?

@alixander
Copy link
Collaborator

Was indeed a bug that's going to be fixed in the next release. Thank you for the report @dzoeteman

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants