Skip to content

Race condition when running multiple instances of quarto #6116

Open

Description

@stefanv

Bug description

When running several instances of quarto render in parallel, errors like these appear:

ERROR: NotFound: No such file or directory (os error 2): copy '/home/stefan/.local/quarto-1.4.76/share/formats/html/quarto.js' -> '/home/stefan/p/resampling/resampling-with/source/site_libs/quarto-html/quarto.js'

NotFound: No such file or directory (os error 2): copy '/home/stefan/.local/quarto-1.4.76/share/formats/html/quarto.js' -> '/home/stefan/p/resampling/resampling-with/source/site_libs/quarto-html/quarto.js'
    at Object.copyFileSync (ext:deno_fs/30_fs.js:80:7)
    at copyFileSync1 (file:///home/stefan/.local/quarto-1.4.76/bin/quarto.js:36992:10)
    at copyTo (file:///home/stefan/.local/quarto-1.4.76/bin/quarto.js:36937:9)
    at doCopy (file:///home/stefan/.local/quarto-1.4.76/bin/quarto.js:36967:9)
    at copyFileIfNewer (file:///home/stefan/.local/quarto-1.4.76/bin/quarto.js:36984:9)
    at copyDependencyFile (file:///home/stefan/.local/quarto-1.4.76/bin/quarto.js:57728:5)
    at copyFile (file:///home/stefan/.local/quarto-1.4.76/bin/quarto.js:57666:13)
    at file:///home/stefan/.local/quarto-1.4.76/bin/quarto.js:57673:50
    at Array.forEach (<anonymous>)
    at processHtmlDependencies (file:///home/stefan/.local/quarto-1.4.76/bin/quarto.js:57673:32)

Steps to reproduce

I don't have a very good way to reproduce, unfortunately, other than to build several chapters of a document in parallel. I hope the problem is straightforward to identify :/

Expected behavior

No response

Actual behavior

No response

Your environment

No response

Quarto check output

$ quarto check

[✓] Checking versions of quarto binary dependencies...
      Pandoc version 3.1.2: OK
      Dart Sass version 1.55.0: OK
      Deno version 1.33.2: OK
[✓] Checking versions of quarto dependencies......OK
[✓] Checking Quarto installation......OK
      Version: 1.4.76
      Path: /home/stefan/.local/quarto-1.4.76/bin

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

[✓] Checking Python 3 installation....OK
      Version: 3.11.1
      Path: /home/stefan/envs/py311/bin/python3
      Jupyter: 5.3.0
      Kernels: python3

(-) Checking Jupyter engine render....0.00s - Debugger warning: It seems that frozen modules are being used, which may
0.00s - make the debugger miss breakpoints. Please pass -Xfrozen_modules=off
0.00s - to python to disable frozen modules.
0.00s - Note: Debugging will proceed. Set PYDEVD_DISABLE_FILE_VALIDATION=1 to disable this validation.
0.00s - Debugger warning: It seems that frozen modules are being used, which may
0.00s - make the debugger miss breakpoints. Please pass -Xfrozen_modules=off
0.00s - to python to disable frozen modules.
0.00s - Note: Debugging will proceed. Set PYDEVD_DISABLE_FILE_VALIDATION=1 to disable this validation.
[✓] Checking Jupyter engine render....OK

[✓] Checking R installation...........OK
      Version: 4.1.3
      Path: /usr/lib64/R
      LibPaths:
        - /home/stefan/R
        - /home/stefan/R-dev
        - /usr/lib64/R/library
        - /usr/share/R/library
      knitr: 1.43
      rmarkdown: 2.22

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

Activity

  1. added
    bug
    on Jul 6, 2023
  2. mcanouil commented on Jul 6, 2023

    @mcanouil
    Collaborator

    Without explaining clearly the steps to reproduce and what you mean by parallel, I'm afraid it isn't "straightforward to identify".

    If I had to guess, you are rendering the same thing multiple times and concurrently. If that's the case, you can't do that because there are temporary files "attached" which get deleted at the end of rendering thus, could be deleted while other files still rely on them.
    Again, without a clear depiction of your setup/use case, we are unlikely to provide further assistance.

  3. added
    needs-repro
    on Jul 6, 2023
  4. stefanv commented on Jul 6, 2023

    @stefanv
    Author

    I think you already touched on part of the problem: possible dependence between documents triggering overlapping builds.

    What I'd like to do is parallelize the building of chapters of a book.
    The way I am doing it right now is to use quarto render chapter.Rmd on each (all in parallel).
    From what you write above, I suspect that quarto render chapter.Rmd may build more than one chapter at a time, perhaps if chapters refer to one another?

    So perhaps the question I should be asking is whether there currently is a reasonable way to parallelize builds.

  5. cscheid commented on Jul 6, 2023

    @cscheid
    Member

    @stefanv There isn't one. This is a known limitation in Quarto, and one we're going to address in 1.5. If you absolutely need parallel rendering, the current best practice is to do so manually in a pre-render script in a manner that's completely managed by yourself, and that doesn't involve parallelizing the calls to pandoc.

  6. removed
    needs-repro
    on Jul 6, 2023
  7. added this to the v1.5 milestone on Nov 28, 2023
  8. modified the milestones: v1.5, Future on Feb 12, 2024
  9. wlandau commented on Dec 1, 2025

    @wlandau

    For me, the race condition happens for some formats and not others. Here's an example report based on ropensci/tarchetypes#230:

    ---
    format: typst
    params:
      value: NA
    ---
    
    Parameter value:
    
    ```{r}
    params$value
    ```
    

    If I run 2 render commands concurrently:

    quarto render report.qmd --output 1.pdf -P value=1
    quarto render report.qmd --output 2.pdf -P value=2

    one of them errors:

    [typst]: Compiling report.typ to report.pdf...error: file not found (searched at reprex/report.typ)

    I'm using Quarto CLI version 1.8.26

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions