Skip to content

🐛 Bug Report: Setting up mermaid docs outdated #27591

@Ryangr0

Description

@Ryangr0

📜 Description

https://backstage.io/docs/features/techdocs/how-to-guides#using-markdown-inline-mermaid
This mentions to add RUN yarn global add @mermaid-js/mermaid-cli. However, yarn global has been removed from yarn a while ago.

👍 Expected behavior

Generate mermaid diagrams without erroring out

👎 Actual Behavior with Screenshots

When I add RUN npm install -g @mermaid-js/mermaid-cli instead of the yarn command, I get this on the actual techdocs page:

Error : Image not created

Args : ['mmdc', '-p', '/tmp/tmp_fdzluvc/puppeteer-config.json', '-o', '/tmp/tmp_fdzluvc/out.svg']

stdout : Generating single mermaid chart

stderr : 
No input file specified, reading from stdin. If you want to specify an input file, please use `-i .` You can use `-i -` to read from stdin and to suppress this warning.


Error: Could not find Chrome (ver. 130.0.6723.116). This can occur if either
 1. you did not perform an installation before running the script (e.g. `npx puppeteer browsers install chrome-headless-shell`) or
 2. your cache path is incorrectly configured (which is: /home/node/.cache/puppeteer).
For (2), check out our guide on configuring puppeteer at https://pptr.dev/guides/configuration.
    at ChromeLauncher.resolveExecutablePath (file:///usr/local/lib/node_modules/@mermaid-js/mermaid-cli/node_modules/puppeteer-core/lib/esm/puppeteer/node/BrowserLauncher.js:266:27)
    at ChromeLauncher.executablePath (file:///usr/local/lib/node_modules/@mermaid-js/mermaid-cli/node_modules/puppeteer-core/lib/esm/puppeteer/node/ChromeLauncher.js:202:25)
    at ChromeLauncher.computeLaunchArguments (file:///usr/local/lib/node_modules/@mermaid-js/mermaid-cli/node_modules/puppeteer-core/lib/esm/puppeteer/node/ChromeLauncher.js:83:37)
    at async ChromeLauncher.launch (file:///usr/local/lib/node_modules/@mermaid-js/mermaid-cli/node_modules/puppeteer-core/lib/esm/puppeteer/node/BrowserLauncher.js:45:28)
    at async run (file:///usr/local/lib/node_modules/@mermaid-js/mermaid-cli/src/index.js:498:17)
    at async cli (file:///usr/local/lib/node_modules/@mermaid-js/mermaid-cli/src/index.js:203:3)

Adding the following to my docker image solved the problem:

RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
    --mount=type=cache,target=/var/lib/apt,sharing=locked \
    apt-get update && \
    apt-get install -y --no-install-recommends chromium && \
    rm -rf /var/lib/apt/lists/*

ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium

👟 Reproduction steps

Should be clear

📃 Provide the context for the Bug.

No response

🖥️ Your Environment

No response

👀 Have you spent some time to check if this bug has been raised before?

  • I checked and didn't find similar issue

🏢 Have you read the Code of Conduct?

Are you willing to submit PR?

None

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:techdocsRelated to the TechDocs Project Areatype:bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions