pistazie / cdk-dia

Automated diagrams of CDK provisioned infrastructure
MIT License
877 stars 37 forks source link

Resource names in diagrams are garbled and not displayed #39

Open kuri-Maron opened 1 year ago

kuri-Maron commented 1 year ago

As you can see in the image, the resource name is not displayed.

This is a diagram generated by executing npx cdk-dia .

I am using v1 of cdk.

Please let me know if you need any information.

diagram

pistazie commented 1 year ago

That's a first-timer! My guess is that Graphviz fonts are somehow missing in your installation / OS. What OS are you on? How did you install Graphviz? Can you try on another OS?

You could also try cdk-dia's (beta) Cytoscape renderer, which should be more OS agnostic.

kuri-Maron commented 1 year ago

What OS are you on?

OS: Amazon Linux 2

$ cat /etc/os-release
NAME="Amazon Linux"
VERSION="2"
ID="amzn"
ID_LIKE="centos rhel fedora"
VERSION_ID="2"
PRETTY_NAME="Amazon Linux 2"
ANSI_COLOR="0;33"
CPE_NAME="cpe:2.3:o:amazon:amazon_linux:2"
HOME_URL="https://amazonlinux.com/"

How did you install Graphviz?

Installed with brew.

$ brew install graphviz

$ brew ls
aom              expat       gdbm        gmp        isl         libffi   libtirpc   libxdmcp            lzo        openssl@1.1  shared-mime-info  xz
aws-sam-cli      fontconfig  gdk-pixbuf  graphite2  jasper      libmpc   libtool    libxext             m4         pango        sqlite            zlib
binutils         freetype    gettext     graphviz   jpeg-turbo  libnsl   libx11     libxml2             mpdecimal  pcre2        unzip             zstd
bzip2            fribidi     giflib      gts        krb5        libpng   libxau     libxrender          mpfr       pixman       util-linux
ca-certificates  gcc         glib        harfbuzz   libavif     librsvg  libxcb     linux-headers@5.15  ncurses    python@3.10  webp
cairo            gd          glibc       icu4c      libedit     libtiff  libxcrypt  lz4                 netpbm     readline     xorgproto

$ dot -V
dot - graphviz version 7.0.6 (20230106.0513)

Can you try on another OS?

Be able to try it on mac os.

Thank you for your answer.

LukaHedt commented 1 year ago

Additional info because I'm also having this error:

Have been trying to run this on an altered Alpine Linux container (dockerfile below, it's a craftCMS container, but is based on Alpine).

Running outside the container on my host machine (macOS) has the text render normally.

Dockerfile:

FROM craftcms/cli:8.0-dev

# Dockerfile we use for the Craft Development Container
# It extends off the CraftCMS CLI container, and creates a user
# that VSCode can use to log in to the contianer with.

# It then runs the ./local_entrypoint.sh file, which will do the initial setup of CraftCMS.
# This process can take upwards of 5 minutes.

COPY ./local_entrypoint.sh /entrypoint.sh

USER root

RUN chmod +x /entrypoint.sh

# Install GraphViz so we can generate the CDK-DIA diagrams
RUN apk add graphviz

# Add a user for executing Development Container commands, etc
RUN echo "Creating development user"
RUN adduser -s /bin/ash -S container_dev www-data

USER www-data

ENTRYPOINT [ "/bin/sh", "/entrypoint.sh" ]
koennjb commented 7 months ago

I also had this issue. I debugged by running Graphviz directly to see any errors/warnings:

dot  diagram.dot -T png > test.png

I noticed this error towards the top:

Fontconfig error: Cannot load default config file

After some Googling, I found that the font config path was not set in my environment. Running this solved the problem for me:

FONTCONFIG_PATH=/etc/fonts npx cdk-dia <... other args>

You could also solve this by adding export FONTCONFIG_PATH=/etc/fonts to your Bash profile.

Hope it helps!