Skip to content

[0.6.7] Importing classes that imports icon variables #2191

@fguinez

Description

@fguinez

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions