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

Computed Captions crash when rendering manuscript to HTML #11117

Open
winniehell opened this issue Oct 19, 2024 · 9 comments
Open

Computed Captions crash when rendering manuscript to HTML #11117

winniehell opened this issue Oct 19, 2024 · 9 comments
Assignees
Labels
bug Something isn't working crossref manuscript Issues related to manuscript output regression Functionality that used to work but now is broken.

Comments

@winniehell
Copy link
Contributor

winniehell commented Oct 19, 2024

Bug description

Computed Captions don't work for HTML output of manuscript project.

Steps to reproduce

Minimal example based on documentation:

---
title: "Reproducible Computed Captions Document"
format: html
engine: jupyter
---

::: {#fig-box}

```{python}
x = [1, 2, 3, 4, 5, 10]
print(x)
```

This dataset has `{python} len(x)` observations.

:::

Reproduction repository: https://github.com/winniehell/quarto-playground/tree/1f3c6ecef794096655619ebd8238c3d98fc510fc

cd test-manuscript/
quarto render --to html

Expected behavior

Figure is rendered, similar to book:

screenshot of the rendered figure in test book project

Actual behavior

Rendering crashes:

⚠️  Import assertions are deprecated. Use `with` keyword, instead of 'assert' keyword.

    const resourceModule = (await import(toFileUrl2(resourcePath("editor/tools/yaml/yaml-intelligence-resources.json")).href, {

  at file:///nix/store/ps94d8icw9hbm9ky3jm3q2vwa672yfgz-quarto-1.5.57/bin/quarto.js:82360:119


Starting python3 kernel...Done

Executing 'index.quarto_ipynb'
  Cell 1/1: ''...Done

Rendering qmd embeds [index.qmd]
Error running filter /nix/store/ps94d8icw9hbm9ky3jm3q2vwa672yfgz-quarto-1.5.57/share/filters/main.lua:
...9ky3jm3q2vwa672yfgz-quarto-1.5.57/share/filters/main.lua:22378: attempt to index a nil value (field 'content')
stack traceback:
        ...9ky3jm3q2vwa672yfgz-quarto-1.5.57/share/filters/main.lua:1233: in local 'filter_fn'
        ...9ky3jm3q2vwa672yfgz-quarto-1.5.57/share/filters/main.lua:635: in function <...9ky3jm3q2vwa672yfgz-quarto-1.5.57/share/filters/main.lua:625>
        (...tail calls...)
        [C]: in ?
        [C]: in method 'walk'
        ...9ky3jm3q2vwa672yfgz-quarto-1.5.57/share/filters/main.lua:557: in function <...9ky3jm3q2vwa672yfgz-quarto-1.5.57/share/filters/main.lua:546>
        (...tail calls...)
        ...9ky3jm3q2vwa672yfgz-quarto-1.5.57/share/filters/main.lua:1334: in local 'callback'
        ...9ky3jm3q2vwa672yfgz-quarto-1.5.57/share/filters/main.lua:1352: in upvalue 'run_emulated_filter_chain'
        ...9ky3jm3q2vwa672yfgz-quarto-1.5.57/share/filters/main.lua:1388: in function <...9ky3jm3q2vwa672yfgz-quarto-1.5.57/share/filters/main.lua:1385>
stack traceback:
        ...9ky3jm3q2vwa672yfgz-quarto-1.5.57/share/filters/main.lua:557: in function <...9ky3jm3q2vwa672yfgz-quarto-1.5.57/share/filters/main.lua:546>
        (...tail calls...)
        ...9ky3jm3q2vwa672yfgz-quarto-1.5.57/share/filters/main.lua:1334: in local 'callback'
        ...9ky3jm3q2vwa672yfgz-quarto-1.5.57/share/filters/main.lua:1352: in upvalue 'run_emulated_filter_chain'
        ...9ky3jm3q2vwa672yfgz-quarto-1.5.57/share/filters/main.lua:1388: in function <...9ky3jm3q2vwa672yfgz-quarto-1.5.57/share/filters/main.lua:1385>

Your environment

NixOS 24.05.20241012.a3f9ad6 (Uakari)

Quarto check output

Quarto 1.5.57

output of quarto check
[✓] Checking versions of quarto binary dependencies...
      Pandoc version 3.1.11: OK
      Dart Sass version 1.77.6: OK
      Deno version 1.46.3: OK
      Typst version 0.11.1: OK
[✓] Checking versions of quarto dependencies......OK
[✓] Checking Quarto installation......OK
      Version: 1.5.57
      Path: /nix/store/ps94d8icw9hbm9ky3jm3q2vwa672yfgz-quarto-1.5.57/bin

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

[✓] Checking LaTeX....................OK
      Using: Installation From Path
      Path: /run/current-system/sw/bin
      Version: undefined

⚠️  Import assertions are deprecated. Use `with` keyword, instead of 'assert' keyword.

    const resourceModule = (await import(toFileUrl2(resourcePath("editor/tools/yaml/yaml-intelligence-resources.json")).href, {

  at file:///nix/store/ps94d8icw9hbm9ky3jm3q2vwa672yfgz-quarto-1.5.57/bin/quarto.js:82360:119

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

[✓] Checking Python 3 installation....OK
      Version: 3.12.5
      Path: /nix/store/wqy1crq4yl12hjlcmvc8c7fsgmliyi4y-python3-3.12.5-env/bin/python3.12
      Jupyter: 5.7.2
      Kernels: python3

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

[✓] Checking R installation...........OK
      Version: 4.4.1
      Path: /nix/store/z70v7siag32vkpwapfzmj84nw6y43gh9-R-4.4.1/lib/R
      LibPaths:
        - /nix/store/daik4k1c0wn51l60crca0bg5rwwb9ic3-r-boot-1.3-30/library
        - /nix/store/lwvbgifsdz5lp04763cy7c5xi7ak4zf3-r-class-7.3-22/library
        - /nix/store/ywxgbh558frpsgdfrv3d84rqb4zz12n5-r-MASS-7.3-61/library
        - /nix/store/5gh44f15yfx1zglp5405v3xr9lzmns7r-r-cluster-2.1.6/library
        - /nix/store/a1hrni8rqgxwfck0r597flf1fg3jj486-r-codetools-0.2-20/library
        - /nix/store/w16lsd6irk7z007f5kz5y10wa7h64iv4-r-foreign-0.8-87/library
        - /nix/store/2icpxrlzfgiaq8xnnrs9jb9y4nyfnrjh-r-KernSmooth-2.23-24/library
        - /nix/store/2ab6xwyjga7fcyjj2f8bqna8r9m3c7rs-r-lattice-0.22-6/library
        - /nix/store/3xnygjx6918c3jy4j19pbadzrc1z9kvw-r-Matrix-1.7-0/library
        - /nix/store/z928qmv92cc69962g3ywah8bya6aca38-r-mgcv-1.9-1/library
        - /nix/store/0dzm06h1xbwa9vpdmzhmhyp5fw38lvgr-r-nlme-3.1-166/library
        - /nix/store/8w40bnvgyz1v3bd9pxn1spy0s4631szm-r-nnet-7.3-19/library
        - /nix/store/cdyvmkzhc4zbm3rc9l9shrbfyyrhknnd-r-rpart-4.1.23/library
        - /nix/store/aqb14s5f7m2g1b8im2qk4aka2lfxgpp2-r-spatial-7.3-17/library
        - /nix/store/plbrhygxk1l22rx09dz6k64fikrdylxm-r-survival-3.7-0/library
        - /nix/store/zmj4vzdb7wv45hrnwlq8iylkxz30k4dc-r-rmarkdown-2.28/library
        - /nix/store/msrlr9vdh4cbg0md58ip425i32sqiaxz-r-bslib-0.8.0/library
        - /nix/store/ivj01b8xi7xsw4dcqk8c9yc5yi9k3d8h-r-base64enc-0.1-3/library
        - /nix/store/wmi5wbcyb8dfy92dqxcmhsxbaijs035v-r-cachem-1.1.0/library
        - /nix/store/svjm71fi93h67bhznkqr95s0k8mfkgaz-r-fastmap-1.2.0/library
        - /nix/store/6ki030nl3r1zwicv1zx5ps5s67bl5hgz-r-rlang-1.1.4/library
        - /nix/store/ymrvw8ikv46cwyx80nkkgkvm151k1plm-r-htmltools-0.5.8.1/library
        - /nix/store/2c8blk9g5lm3f7pmcy1pm3xzwj42qjnk-r-digest-0.6.36/library
        - /nix/store/gqsj71kl85bwnmqzxiyvhzc2622rhb5g-r-jquerylib-0.1.4/library
        - /nix/store/l0a09sccsi1dkg63c29mkpyggvb08z79-r-jsonlite-1.8.8/library
        - /nix/store/wkmhssmavkcjc1dabvzil839gsjygg1j-r-lifecycle-1.0.4/library
        - /nix/store/bwg6lqnpnpiv0fsq8ixm1a5phfmw8hn1-r-cli-3.6.3/library
        - /nix/store/5056ych2577zb9gyfy4qpj7h5fdf9ad1-r-glue-1.7.0/library
        - /nix/store/zm6jfjg2ssxh203mx4kh45xhrhfkdn8x-r-memoise-2.0.1/library
        - /nix/store/q2rzc6dhg84mmny6xjz42v2ac9hbpywf-r-mime-0.12/library
        - /nix/store/vzbfrr622313zh776r0aqf7y78fbrh28-r-sass-0.4.9/library
        - /nix/store/fzmm775ppypmwxxygm2rdr9vrvxnmr02-r-R6-2.5.1/library
        - /nix/store/pha01w01l40dsycyfnnvagzvv65zhd59-r-fs-1.6.4/library
        - /nix/store/v4azfk4cdz5rk1l0255p40sfll3kqc90-r-rappdirs-0.3.3/library
        - /nix/store/pi2whxkrj13cyqysc34w8xlrmlr26ckn-r-evaluate-0.24.0/library
        - /nix/store/klfvbq1ga9dmzs0z28b0r7v2qvdxgf3w-r-fontawesome-0.5.2/library
        - /nix/store/2jz6wc7wm1ajvi9baqsx0jv7c999h8cj-r-knitr-1.48/library
        - /nix/store/d3d5w3sjlchd3hq8fm7bm33zh8xgmia2-r-highr-0.11/library
        - /nix/store/jnfjcr31zmy9nnzm2li43hhp6rq8mjas-r-xfun-0.47/library
        - /nix/store/69w2fsnbq4dkgzg2prkd69k4icmk8mqc-r-yaml-2.3.10/library
        - /nix/store/1hgvyfnqaaj7vy7jnnv27a3y6gja081q-r-tinytex-0.52/library
        - /nix/store/z70v7siag32vkpwapfzmj84nw6y43gh9-R-4.4.1/lib/R/library
      knitr: 1.48
      rmarkdown: 2.28

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

also reproduced on latest main (71945532e1fc1a5cf113117f6d5ff5bee3991797)

@winniehell winniehell added the bug Something isn't working label Oct 19, 2024
@winniehell
Copy link
Contributor Author

@mcanouil
Copy link
Collaborator

mcanouil commented Oct 19, 2024

Quarto 1.5.57 is not supposed to use:

  • Deno 1.46.3, it uses 1.41.0.
  • Dart Sass version 1.77.6: OK
  • Typst 0.11.1, it uses Typst 0.11

Your installation of Quarto is wrong.
Looking at your system, I believe you are using a non official Quarto (i.e., not packages by the Quarto team).

Unfortunately, the Quarto team does not provide support for wrongly packaged Quarto CLI.

@winniehell
Copy link
Contributor Author

winniehell commented Oct 19, 2024

@mcanouil thank you for the fast response! 🚀

Unfortunately, the Quarto team does not provide support fro wrongly packages Quarto CLI.

I understand and respect that. I was able to reproduce on latest main (71945532e1fc1a5cf113117f6d5ff5bee3991797) as well:

$ ~/quarto-cli/package/dist/bin/quarto render --to html

Starting python3 kernel...Done

Executing 'index.quarto_ipynb'
  Cell 1/1: ''...Done

Rendering qmd embeds [index.qmd]
Error running filter ~/quarto-cli/src/resources/filters/main.lua:
...i/src/resources/filters/./customnodes/floatreftarget.lua:965: attempt to index a nil value (field 'content')
stack traceback:
        ...s/2024/quarto-cli/src/resources/filters/./ast/render.lua:46: in local 'filter_fn'
        ...4/quarto-cli/src/resources/filters/./ast/customnodes.lua:154: in function <...4/quarto-cli/src/resources/filters/./ast/customnodes.lua:144>
        (...tail calls...)
        [C]: in ?
        [C]: in method 'walk'
        ...4/quarto-cli/src/resources/filters/./ast/customnodes.lua:76: in function <...4/quarto-cli/src/resources/filters/./ast/customnodes.lua:65>
        (...tail calls...)
        .../quarto-cli/src/resources/filters/./ast/runemulation.lua:82: in local 'callback'
        .../quarto-cli/src/resources/filters/./ast/runemulation.lua:100: in upvalue 'run_emulated_filter_chain'
        .../quarto-cli/src/resources/filters/./ast/runemulation.lua:136: in function <.../quarto-cli/src/resources/filters/./ast/runemulation.lua:133>
stack traceback:
        ...4/quarto-cli/src/resources/filters/./ast/customnodes.lua:76: in function <...4/quarto-cli/src/resources/filters/./ast/customnodes.lua:65>
        (...tail calls...)
        .../quarto-cli/src/resources/filters/./ast/runemulation.lua:82: in local 'callback'
        .../quarto-cli/src/resources/filters/./ast/runemulation.lua:100: in upvalue 'run_emulated_filter_chain'
        .../quarto-cli/src/resources/filters/./ast/runemulation.lua:136: in function <.../quarto-cli/src/resources/filters/./ast/runemulation.lua:133>
ERROR: Error
    at renderFiles (file://~/quarto-cli/src/command/render/render-files.ts:350:23)
    at eventLoopTick (ext:core/01_core.js:175:7)
    at async renderProject (file://~/quarto-cli/src/command/render/project.ts:457:23)
    at async Command.actionHandler (file://~/quarto-cli/src/command/render/cmd.ts:248:26)
    at async Command.execute (https://deno.land/x/[email protected]/command/command.ts:1948:7)
    at async Command.parseCommand (https://deno.land/x/[email protected]/command/command.ts:1780:14)
    at async quarto (file://~/quarto-cli/src/quarto.ts:156:5)
    at async file://~/quarto-cli/src/quarto.ts:185:5
    at async mainRunner (file://~/quarto-cli/src/core/main.ts:35:5)
    at async file://~/quarto-cli/src/quarto.ts:175:3
quarto check
Quarto 99.9.9
[✓] 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: 99.9.9
      commit: 71945532e1fc1a5cf113117f6d5ff5bee3991797
      Path: ~/quarto-cli/package/dist/bin

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

[✓] Checking LaTeX....................OK
      Using: Installation From Path
      Path: /run/current-system/sw/bin
      Version: undefined

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

[✓] Checking Python 3 installation....OK
      Version: 3.12.5
      Path: ~/quarto-playground/.venv/bin/python3
      Jupyter: 5.7.2
      Kernels: python3

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

[✓] Checking R installation...........(None)

      Unable to locate an installed version of R.
      Install R from https://cloud.r-project.org/

@mcanouil
Copy link
Collaborator

mcanouil commented Oct 19, 2024

Thanks for the update and confirming the issue is not your installation1

I can reproduce on main as well but it's unrelated to computed caption (i.e., inline code in caption).

  1. Create a Manuscript project

    quarto create project manuscript
  2. Add a cross-reference div using Python/Jupyter (it works with R/Knitr)

    ::: {#fig-default}
    ```{python}
    print("hello world")
    ```
    
    A caption for the figure.
    :::

    or a Python code cell with YAML

    ```{python}
    #| label: fig-default
    #| fig-cap: A caption for the figure.
    print("hello world")
    ```
  3. Render the project

    quarto render --execute

Note that if the content of the code cell is a real figure, it works.
Custom float cross-reference does not work either with Python/jupyter code cell.

I am not very familiar with the Manuscript project type, so I might missed something on how it works or supposed to work.

Footnotes

  1. well, to be fair, it is an issue itself as you will get unexpected behaviour since the dependencies can change while Quarto code is validated for particular dependencies' version, see https://github.com/quarto-dev/quarto-cli/blob/main/configuration)

@mcanouil
Copy link
Collaborator

In the end I think this is a duplicate but a cleaner reproduction of:

@mcanouil
Copy link
Collaborator

The above example does work on 1.4.557.

I'm bisecting this.

@winniehell
Copy link
Contributor Author

winniehell commented Oct 19, 2024

Note that if the content of the code cell is a real figure, it works.

I'm not sure if that is would you mean but I can reproduce when plotting as well. I just wanted to avoid matplotlib in the minimal example.

---
title: "Reproducible Quarto Document"
format: html
engine: jupyter
---

::: {#fig-box}

```{python}
#| echo: false
import matplotlib.pyplot as plt

x = [1, 2, 3, 4, 5, 10]
p = plt.boxplot(x)
plt.show()
```

This dataset has `{python} len(x)` observations.

:::

This however leads to the slightly different error message from #11088:

Error running filter ~/quarto-cli/src/resources/filters/main.lua:
Block, list of Blocks, or compatible element expected, got table
        while retrieving function argument content
        while retrieving arguments for function Div
stack traceback:
        ...i/src/resources/filters/./customnodes/floatreftarget.lua:955: in field 'render'

@mcanouil
Copy link
Collaborator

mcanouil commented Oct 19, 2024

The Pandoc update in 1.5 broke this.

I'm not sure if that is would you mean but I can reproduce when plotting as well. I just wanted to avoid matplotlib in the minimal example.

I was not on the not working Quarto.
It's also broken indeed.

@mcanouil mcanouil added the regression Functionality that used to work but now is broken. label Oct 19, 2024
@winniehell
Copy link
Contributor Author

Unfortunately, the Quarto team does not provide support fro wrongly packages Quarto CLI.

I have moved my follow-up question to #11118 because it is off-topic here.

@cscheid cscheid self-assigned this Oct 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working crossref manuscript Issues related to manuscript output regression Functionality that used to work but now is broken.
Projects
None yet
Development

No branches or pull requests

3 participants