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

ERROR: Internal Error: Couldn't find an svg element in svg string #11775

Closed
pascalsiemsen opened this issue Jan 3, 2025 · 7 comments
Closed
Labels
duplicate This issue or pull request already exists

Comments

@pascalsiemsen
Copy link

pascalsiemsen commented Jan 3, 2025

Bug description

I have a quarto document that includes text, a mermaid diagram and a ggplot graph in a r code chunk. Everything used to work fine when rendering to pdf but now I get this error.

If I remove all plots, the document renders fine. I've included a minimal example below.

As the error message says I should consider reporting the bug, I thought to do so.

ERROR: Internal Error: Couldn't find an svg element in svg string

This is a bug in quarto. We apologize for the inconvenience.
Please consider reporting it at https://github.com/quarto-dev/quarto-cli. Thank you!

Stack trace:
    at resolveSize (file:///Applications/quarto/bin/quarto.js:82001:15)
    at eventLoopTick (ext:core/01_core.js:175:7)
    at async makePng (file:///Applications/quarto/bin/quarto.js:82344:55)
    at async makeDefault (file:///Applications/quarto/bin/quarto.js:82396:24)
    at async Object.cell (file:///Applications/quarto/bin/quarto.js:82419:20)
    at async Promise.all (index 0)
    at async Object.document (file:///Applications/quarto/bin/quarto.js:39218:25)
    at async handleLanguageCells (file:///Applications/quarto/bin/quarto.js:39188:42)
    at async file:///Applications/quarto/bin/quarto.js:85737:51
    at async withTimingAsync (file:///Applications/quarto/bin/quarto.js:16889:25)

Steps to reproduce

---
title: "Error test"
format: pdf
---

## Quarto



```{mermaid}
%%| label: fig-t
%%| fig-cap: "test"

flowchart LR

A[A] --> B[B]
B --> C[C]

```

```{r}
#| echo: false
#| label: fig-confounder
#| fig-cap: "Confouding Example"


# would need the package "pacman" for the next line
# loading ggdag and ggplot2 should be enough though 

pacman::p_load(ggdag, dagitty, ggplot2, ggrepel, tidyverse)
set.seed(239)

theme_set(theme_dag())

confounder <- dagify(X ~ C,
  Y ~ C,
  exposure = "X",
  outcome = "Y"
)

d <- ggdag(confounder, layout = "tree")

d + expand_plot(expand_x = expansion(c(1, 1)), expand_y = expansion(c(1, 1)))

```

Expected behavior

Render the quarto document and output a pdf.

Actual behavior

The error message above.

Your environment

  • Positron Version: 2025.01.0 (Universal) build 39
  • macOS Sequoia V 15.2

Quarto check output

Quarto 1.7.5
[✓] Checking environment information...
      Quarto cache location: /Users/pascal/Library/Caches/quarto
[✓] Checking versions of quarto binary dependencies...
      Pandoc version 3.4.0: OK
      Dart Sass version 1.70.0: OK
      Deno version 1.46.3: OK
      Typst version 0.11.0: OK
[✓] Checking versions of quarto dependencies......OK
[✓] Checking Quarto installation......OK
      Version: 1.7.5
      Path: /Applications/quarto/bin

[✓] Checking tools....................OK
      Chromium: 869685
      TinyTeX: (not installed)

[✓] Checking LaTeX....................OK
      Using: Installation From Path
      Path: /Library/TeX/texbin
      Version: 2024

[✓] Checking basic markdown render....OK

[✓] Checking Python 3 installation....OK
      Version: 3.12.4 (Conda)
      Path: /Users/pascal/miniconda3/bin/python
      Jupyter: (None)

      Jupyter is not available in this Python installation.
      Install with conda install jupyter

[✓] Checking R installation...........OK
      Version: 4.4.1
      Path: /Library/Frameworks/R.framework/Resources
      LibPaths:
        - /Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library
      knitr: 1.48
      rmarkdown: 2.28

[✓] Checking Knitr engine render......OK

@pascalsiemsen pascalsiemsen added the bug Something isn't working label Jan 3, 2025
@mcanouil
Copy link
Collaborator

mcanouil commented Jan 3, 2025

Could you properly format your post using code blocks for code and terminal outputs? Thanks.
If your code contains code blocks, you need to enclose it using more backticks, i.e., usually four ````.
See https://quarto.org/bug-reports.html#formatting-make-githubs-markdown-work-for-us.

@mcanouil
Copy link
Collaborator

mcanouil commented Jan 3, 2025

Are all the R packages and both R code cell and mermaid cell required?
Could you remove everything not absolutely required?

We unfortunately don't have the time to figure out what's really needed to what's not, such as all your R packages (including pacman), so you have to make the example small as requested.
Thank you for your understanding.

@mcanouil
Copy link
Collaborator

mcanouil commented Jan 3, 2025

I strongly suspect, the R code is completely unnecessary and the issue comes from the mermaid cell which needs for LaTeX/PDF to use Chromium-based browser to turn the HTML diagram into an actual image.

If you have a chromium-based browser (Chrome, Edge, Brave, Chromium, etc.), I suggest to use it instead of the one installed by Quarto via quarto install chromium.

export QUARTO_CHROMIUM=...
quarto render document.qmd

@cscheid
Copy link
Collaborator

cscheid commented Jan 3, 2025

Thanks for the report!

Independently of the cause, we should consider changing that message a bit.

@pascalsiemsen
Copy link
Author

Both points turned out to be true. The culprit was the Mermaid code and removing the quarto chromium install while installing chrome solved the issue. The document renders now and adding the R code back in is also not a problem.

Thanks for the quick replies. And btw, thanks for all the work you put into quarto. Makes writing a PhD that little bit more fun.

@mcanouil
Copy link
Collaborator

mcanouil commented Jan 3, 2025

Thanks, this confirmed two things:

  • the message needs to be improved.
  • the version of Chromium installed by Quarto is outdated.

@mcanouil mcanouil added installers issues with packages from package managers, installers, etc. chromium diagrams-mermaid Mermaid diagrams labels Jan 3, 2025
@mcanouil
Copy link
Collaborator

mcanouil commented Jan 3, 2025

Duplicate of #10961

@mcanouil mcanouil marked this as a duplicate of #10961 Jan 3, 2025
@mcanouil mcanouil closed this as completed Jan 3, 2025
@mcanouil mcanouil added duplicate This issue or pull request already exists and removed bug Something isn't working diagrams-mermaid Mermaid diagrams installers issues with packages from package managers, installers, etc. chromium labels Jan 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

3 participants