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

[0.6.7] Importing classes that imports icon variables #2191

Open
fguinez opened this issue Nov 5, 2024 · 0 comments
Open

[0.6.7] Importing classes that imports icon variables #2191

fguinez opened this issue Nov 5, 2024 · 0 comments

Comments

@fguinez
Copy link

fguinez commented Nov 5, 2024

The problem

I found an issue when importing classes that in turn import icon variables. This fails in 0.6.7, but works in 0.6.6.

The errors only occur when I use imports from c.d2 as icons. I tried changing icon: to label: in b.d2 and it worked. I tried importing everything from a.d2 and it works too, but this doesn't really fit my use case.

I am not sure but maybe it is something related to #2066, because the error message indicates that a remote image has been detected as a local image. But I don't know why this happens with this specific importing structure.

How to replicate

I have the following files in the same directory:

# a.d2 (the file to compile)
...@b.d2


a1: {
    class: Ecs
}

a2: {
    class: Lambda
}

a1 -> a2
# b.d2 (the file with the classes)
...@c.d2

classes: {
    Ecs: {
        shape: "circle"
        icon: ${icons.ecs}
    }

    Lambda: {
        shape: "hexagon"
        icon: ${icons.lambda}
    }
}
# c.d2 (the file with the icons)
vars: {
    icons: {
        ecs: "https://icons.terrastruct.com/aws%2FCompute%2FAmazon-Elastic-Container-Service.svg"
        lambda: "https://icons.terrastruct.com/aws%2FCompute%2FAWS-Lambda.svg"
    }    
}

Depending on the version of D2 that I'm using, the behavior is different.

  • With version 0.6.6 I get the following diagram:
image
  • With version 0.6.7 I get the following errors:
Errors
err: failed to bundle .: read .: is a directory
err: failed to compile -: failed to bundle local images: [.]

Set up

  • I'm running D2 from VSCode 1.93.1
  • D2 VSCode extension v0.8.8
  • macOS 15.0.1 (chip M2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

No branches or pull requests

1 participant