Skip to content

pandoc: openBinaryFile: does not exist (No such file or directory) when using render() in parallel #1632

Closed

Description

@gorgitko

By filing an issue to this repo, I promise that

  • I have fully read the issue guide at https://yihui.name/issue/.
  • I have provided the necessary information about my issue.
    • If I'm asking a question, I have already asked it on Stack Overflow or RStudio Community, waited for at least 24 hours, and included a link to my question there.
    • If I'm filing a bug report, I have included a minimal, self-contained, and reproducible example, and have also included xfun::session_info('rmarkdown'). I have upgraded all my packages to their latest versions (e.g., R, RStudio, and R packages), and also tried the development version: remotes::install_github('rstudio/rmarkdown').
    • If I have posted the same issue elsewhere, I have also mentioned it in this issue.
  • I have learned the Github Markdown syntax, and formatted my issue correctly.

I understand that my issue may be closed if I don't fulfill my promises.


When I am using rmarkdown::render() in BiocParallel::bplapply(), Pandoc throws this error:
pandoc: /tmp/RtmpW06rTD/rmarkdown-str3bc26dd971b5.html: openBinaryFile: does not exist (No such file or directory). I am using Pandoc version 2.7.3 and development version of rmarkdown. Everything works fine when I use BPPARAM = SerialParam() in bplapply (i.e. it will disable parallel processing).

to_render.Rmd:

---
output:
  html_document:
    code_folding: "none"
    df_print: "paged"
    toc: false
    number_sections: false
    theme: "united"
    self_contained: true
params: 
  title: "Document"
---

---
title: `r params$title`
---

```{r}
DT::datatable(
  mtcars,
  filter = "top",
  width = "100%",
  class = "display compact"
)
```

render.R:

library(glue)
library(rmarkdown)
library(BiocParallel)

N_CPUS <- 8

OUTPUT_DIR <- "rendered"
OUTPUT_FILES <- 1:10

BPPARAM <- MulticoreParam(workers = N_CPUS)

dir.create(OUTPUT_DIR, showWarnings = FALSE)

bplapply(OUTPUT_FILES, function(i) {
  intermediates_dir <- glue("{i}_intermediates_dir")

  render(
    "to_render.Rmd",
    output_file = glue("{i}.html"),
    output_dir = OUTPUT_DIR,
    params = list(title = glue("Document {i}")),
    intermediates_dir = intermediates_dir
  )

  system(glue("rm -r {intermediates_dir}"))
}, BPPARAM = BPPARAM)

Output from render.R:

> library(glue)

> library(rmarkdown)

> library(BiocParallel)

> N_CPUS <- 8

> OUTPUT_DIR <- "rendered"

> OUTPUT_FILES <- 1:10

> BPPARAM <- MulticoreParam(workers = N_CPUS)

> dir.create(OUTPUT_DIR, showWarnings = FALSE)

> bplapply(OUTPUT_FILES, function(i) {
+   intermediates_dir <- glue("{i}_intermediates_dir")
+ 
+   render(
+     "to_render.Rmd",
+     output_file  .... [TRUNCATED] 


processing file: to_render.Rmd
  |................................                                 |  50%
  ordinary text without R code

  |.................................................................| 100%
label: unnamed-chunk-1

output file: /ssd/ownCloud/temp/rmarkdown_parallel_reprex/3_intermediates_dir/to_render.knit.md

/usr/bin/pandoc +RTS -K512m -RTS /ssd/ownCloud/temp/rmarkdown_parallel_reprex/3_intermediates_dir/to_render.utf8.md --to html4 --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash+smart --output /ssd/ownCloud/temp/rmarkdown_parallel_reprex/rendered/3.html --email-obfuscation none --self-contained --standalone --section-divs --template /home/novotnyj/R/x86_64-pc-linux-gnu-library/3.6/rmarkdown/rmd/h/default.html --no-highlight --variable highlightjs=1 --variable 'theme:united' --include-in-header /tmp/Rtmpiblzto/rmarkdown-str42fb6ef4dcc8.html --mathjax --variable 'mathjax-url:https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML' --metadata pagetitle=/ssd/ownCloud/temp/rmarkdown_parallel_reprex/3_intermediates_dir/to_render.utf8.md 

Output created: rendered/3.html
pandoc: /tmp/Rtmpiblzto/rmarkdown-str42fc5c014392.html: openBinaryFile: does not exist (No such file or directory)


processing file: to_render.Rmd
  |................................                                 |  50%
  ordinary text without R code

  |.................................................................| 100%
label: unnamed-chunk-1

output file: /ssd/ownCloud/temp/rmarkdown_parallel_reprex/4_intermediates_dir/to_render.knit.md

/usr/bin/pandoc +RTS -K512m -RTS /ssd/ownCloud/temp/rmarkdown_parallel_reprex/4_intermediates_dir/to_render.utf8.md --to html4 --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash+smart --output /ssd/ownCloud/temp/rmarkdown_parallel_reprex/rendered/4.html --email-obfuscation none --self-contained --standalone --section-divs --template /home/novotnyj/R/x86_64-pc-linux-gnu-library/3.6/rmarkdown/rmd/h/default.html --no-highlight --variable highlightjs=1 --variable 'theme:united' --include-in-header /tmp/Rtmpiblzto/rmarkdown-str42fc698c38a7.html --mathjax --variable 'mathjax-url:https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML' --metadata pagetitle=/ssd/ownCloud/temp/rmarkdown_parallel_reprex/4_intermediates_dir/to_render.utf8.md 

Output created: rendered/4.html
pandoc: /tmp/Rtmpiblzto/rmarkdown-str42fa67445478.html: openBinaryFile: does not exist (No such file or directory)
pandoc: /tmp/Rtmpiblzto/rmarkdown-str42ff5be0d7db.html: openBinaryFile: does not exist (No such file or directory)
pandoc: /tmp/Rtmpiblzto/rmarkdown-str42fd4840f002.html: openBinaryFile: does not exist (No such file or directory)
Error: BiocParallel errors
  element index: 2, 5, 7, 10
  first error: pandoc document conversion failed with error 1

Pandoc and session info:

> pandoc_exec()
[1] "/usr/bin/pandoc"
> pandoc_version()
[1] ‘2.7.3’
> xfun::session_info()
R version 3.6.1 (2019-07-05)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Linux Mint 19, RStudio 1.2.1335

Locale:
  LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8     LC_MONETARY=cs_CZ.UTF-8    LC_MESSAGES=en_US.UTF-8   
  LC_PAPER=cs_CZ.UTF-8       LC_NAME=C                  LC_ADDRESS=C               LC_TELEPHONE=C             LC_MEASUREMENT=cs_CZ.UTF-8 LC_IDENTIFICATION=C       

Package version:
  base64enc_0.1.3      BH_1.69.0.1          BiocParallel_1.18.1  compiler_3.6.1       digest_0.6.20        evaluate_0.14        formatR_1.7          futile.logger_1.4.3 
  futile.options_1.0.1 glue_1.3.1           graphics_3.6.1       grDevices_3.6.1      highr_0.8            htmltools_0.3.6      jsonlite_1.6         knitr_1.24          
  lambda.r_1.2.3       magrittr_1.5         markdown_1.1         methods_3.6.1        mime_0.7             parallel_3.6.1       Rcpp_1.0.2           rmarkdown_1.15.1    
  snow_0.4.3           stats_3.6.1          stringi_1.4.3        stringr_1.4.0        tinytex_0.15         tools_3.6.1          utils_3.6.1          xfun_0.9            
  yaml_2.2.0    

Activity

  1. abalter commented on Oct 23, 2019

    @abalter
  2. gorgitko commented on Oct 24, 2019

    @gorgitko
    ContributorAuthor

    In my opinion, the issue has still not been completely resolved. I'm running into this error myself in a much more simple situation--no network drives or other unusual configurations.

    I can confirm this is happening on local computer using local drives, not network ones.

  3. gorgitko commented on Oct 24, 2019

    @gorgitko
    ContributorAuthor

    So I have examined a little bit how is actually rmarkdown using pandoc and especially what is the temporary file pandoc cannot find:

    pandoc: /tmp/RtmpGXCEhW/rmarkdown-str7381eaa5d53.html: openBinaryFile: does not exist (No such file or directory)
    

    I have found that this file is probably somehow used for navbars, but more important is this function:

    # temp files created by as_tmpfile() cannot be immediately removed because they
    # are needed later by the pandoc conversion; we have to clean up the temp files
    # that have the pattern specified in `tmpfile_pattern` when render() exits
    clean_tmpfiles <- function() {
      unlink(list.files(
        tempdir(), sprintf("^%s[0-9a-f]+[.]html$", tmpfile_pattern), full.names = TRUE
      ))
    }
    

    called in render():

      # render() may call itself, e.g., in discover_rmd_resources(); in this case,
      # we should not clean up temp files in the nested render() call, but wait
      # until the top-level render() exits to clean up temp files
      .globals$level <- .globals$level + 1L  # increment level in a nested render()
      on.exit({
        .globals$level <- .globals$level - 1L
        if (.globals$level == 0) clean_tmpfiles()
      }, add = TRUE)
    

    So what is actually happening? After render() call is finished, this clean_tmpfiles function removes all rmarkdown temporary files. And because in parallel calling the temporary directory is remaining the same, it will also remove temporary files for other render() calls.

    I can confirm this dirty solution works (put this after library(rmarkdown)):

    clean_tmpfiles_mod <- function() {
      message("Calling clean_tmpfiles_mod()")
    }
    
    assignInNamespace("clean_tmpfiles", clean_tmpfiles_mod, ns = "rmarkdown")
    

    Would be great if developers add something like clean_tmpfiles = TRUE to render() parameters and users could then call clean_tmpfiles() by themselves.

    Full modified render.R:

    library(glue)
    library(rmarkdown)
    library(BiocParallel)
    
    clean_tmpfiles_mod <- function() {
      message("Calling clean_tmpfiles_mod()")
    }
    
    assignInNamespace("clean_tmpfiles", clean_tmpfiles_mod, ns = "rmarkdown")
    
    N_CPUS <- 8
    
    OUTPUT_DIR <- "rendered"
    OUTPUT_FILES <- 1:10
    
    BPPARAM <- MulticoreParam(workers = N_CPUS)
    
    dir.create(OUTPUT_DIR, showWarnings = FALSE)
    
    bplapply(OUTPUT_FILES, function(i) {
      intermediates_dir <- glue("{i}_intermediates_dir")
    
      render(
        "to_render.Rmd",
        output_file = glue("{i}.html"),
        output_dir = OUTPUT_DIR,
        params = list(title = glue("Document {i}")),
        intermediates_dir = intermediates_dir
      )
    
      system(glue("rm -r {intermediates_dir}"))
    }, BPPARAM = BPPARAM)
    
  4. JayMMTL commented on Apr 29, 2020

    @JayMMTL

    We're using a basic Pandoc script in bash to merge multiple files:

    pandoc lf/lf_01.txt master.md lf/lf_02.txt master_fr.md lf/lf_03.txt master_es.md lf/lf_04.txt master_pt.md lf/lf_05.txt master_de.md lf/lf_06.txt master_it.md lf/lf_07.txt master_ja.md lf/lf_08.txt master.md lf/lf_09.txt > output.html

    Is it possible to add a function to prevent clearing the temp files which causes the "openBinaryFile: does not exist (No such file or directory)" error in this medium?

  5. gorgitko commented on Apr 30, 2020

    @gorgitko
    ContributorAuthor

    @JayMMTL I am not sure how is this connected to rendering Rmds from within R. If this is the case, you can use the snippet I have provided to replace the clean_tmpfiles() function, which causes this problem.

  6. Nicktz commented on May 18, 2020

    @Nicktz

    @gorgitko Your solution worked perfectly for me thanks.
    Working on a linux vm building rmarkdown files in parallel.
    Spent whole afternoon trying to figure this out and in the end your black magic dirty solution did the trick. Thanks!

  7. agilebean commented on May 19, 2020

    @agilebean

    Thanks @gorgitko for explaining the root cause.
    Unfortunately, your solution does not work on my Macbook Pro 16.
    It does call your mod function but the error 1 is thrown before:

    <div id=: openBinaryFile: does not exist (No such file or directory)
    Error: pandoc document conversion failed with error 1
    Calling clean_tmpfiles_mod()
    

    I also tried the set off a flag mentioned in several posts:
    create_report(iris, config = configure_report(add_plot_str = FALSE))

    SessionInfo:

    R version 3.6.2 (2019-12-12)
    Platform: x86_64-apple-darwin15.6.0 (64-bit)
    Running under: macOS Catalina 10.15.4
    
    Matrix products: default
    BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
    LAPACK: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRlapack.dylib
    
    locale:
    [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
    
    attached base packages:
    [1] stats     graphics  grDevices utils     datasets  methods   base     
    
    other attached packages:
     [1] knitr_1.28.7             data.table_1.12.8        DataExplorer_0.8.1       rmarkdown_2.1.4         
     [5] likert_1.3.5             xtable_1.8-4             machinelearningtools_0.1 forcats_0.5.0           
     [9] stringr_1.4.0            dplyr_0.8.99.9003        purrr_0.3.4              readr_1.3.1             
    [13] tidyr_1.0.2              tibble_3.0.1             ggplot2_3.3.0            tidyverse_1.3.0.9000    
    [17] magrittr_1.5             googlesheets_0.3.0       psych_1.9.12.31         
    
    loaded via a namespace (and not attached):
     [1] Rcpp_1.0.4.6      lubridate_1.7.8   lattice_0.20-38   assertthat_0.2.1  packrat_0.5.0    
     [6] digest_0.6.25     utf8_1.1.4        R6_2.4.1          cellranger_1.1.0  plyr_1.8.6       
    [11] backports_1.1.7   reprex_0.3.0      evaluate_0.14     highr_0.8         httr_1.4.1       
    [16] pillar_1.4.4      rlang_0.4.6.9000  curl_4.3          readxl_1.3.1      rstudioapi_0.11  
    [21] labeling_0.3      htmlwidgets_1.5.1 igraph_1.2.5      munsell_0.5.0     broom_0.5.6      
    [26] compiler_3.6.2    modelr_0.1.6      xfun_0.13         pkgconfig_2.0.3   mnormt_1.5-5     
    [31] htmltools_0.4.0   tidyselect_1.1.0  gridExtra_2.3     fansi_0.4.1       crayon_1.3.4     
    [36] dbplyr_1.4.3      withr_2.2.0       grid_3.6.2        nlme_3.1-142      jsonlite_1.6.1   
    [41] gtable_0.3.0      lifecycle_0.2.0   DBI_1.1.0         scales_1.1.1      cli_2.0.2        
    [46] stringi_1.4.6     farver_2.0.3      reshape2_1.4.4    fs_1.4.1          xml2_1.3.1       
    [51] ellipsis_0.3.1    generics_0.0.2    vctrs_0.3.0.9000  tools_3.6.2       glue_1.4.1       
    [56] networkD3_0.4     hms_0.5.3         yaml_2.2.1        parallel_3.6.2    colorspace_1.4-1 
    [61] rvest_0.3.5       haven_2.2.0 
    

    Any ideas??

  8. gorgitko commented on May 19, 2020

    @gorgitko
    ContributorAuthor

    @agilebean I am not sure if clean_tmpfiles_mod() is correctly replacing the original clean_tmpfiles(). It should echo "Calling clean_tmpfiles_mod()". Make sure you start with a clean environment and try my example first.

  9. dcaud commented on Dec 11, 2020

    @dcaud

    I continue to get random messages about files not existing.

  10. dcaud commented on Dec 12, 2020

    @dcaud

    Some version of an insistently retrying function may work (although clearly not ideal, it seems to be helping me avoid this somewhat random error):

    library(purrr)
    rate <- rate_backoff(pause_base = 0.1, pause_min = 0.005, max_times = 10)
    insistent_render <- insistently(rmarkdown::render, rate, quiet = FALSE)
    

    then call insistent_render instead of rmarkdown::render

  11. added
    theme: pandoc
    on Jan 14, 2021
  12. ktd2001 commented on Mar 17, 2021

    @ktd2001

    Any suggestions on how to fix this? I am running it in R version 4.04

    pandoc.exe: \: openBinaryFile: does not exist (No such file or directory)
    Warning: Error in : pandoc document conversion failed with error 1
    128: stop
    127: pandoc_convert
    126: convert
    125: render
    124: discover_rmd_resources
    123: find_external_resources
    122: copy_render_intermediates
    121: output_format$intermediates_generator
    120:
    115:
    99: doc
    98: renderUI
    97: func
    84: renderFunc
    83: output$reactivedoc
    3:
    1: rmarkdown::run

  13. cderv commented on Mar 17, 2021

    @cderv
    Collaborator

    @ktd2001
    Which OS are you on ?
    Which Pandoc version do you use ? rmarkdown::pandoc_version()
    Where are you files located ? On a network drive ?

    Can you share the file with the issue so we can try reproduce ? With any other element that could help us understand ?

  14. ktd2001 commented on Mar 18, 2021

    @ktd2001
  15. gorgitko commented on Mar 18, 2021

    @gorgitko
    ContributorAuthor

    @cderv I am just curious if anyone at RStudio has looked into the problem I proposed in the #1632 (comment)

    TLDR: Allow users to specify whether clean_tmpfiles() will be run after render() has finished. Possibly allow users to run it manually.

    Anyway, I think each rendered Rmd should get its own directory in tempdir(); that would basically avoid this problem.

    Thank you for looking at this 🙂

  16. 10 remaining items

  17. moved this from Backlog to To discuss / To plan in R Markdown Team Projectson Sep 21, 2022
  18. moved this from To discuss / To plan to Backlog in R Markdown Team Projectson Sep 27, 2022
  19. tylerlittlefield commented on Aug 18, 2023

    @tylerlittlefield

    I was getting similar errors, but had nothing to do with running in parallel. Instead, the withBinaryFile: does not exist (No such file or directory) error truly wasn't able to find the file it needed. In case someone else runs into this, here was my thought process.

    While containerizing a report, I hit the following error:

    pandoc: /usr/local/lib/R/site-library/fontawesome/fontawesome/css/../webfonts/fa-v4compatibility.woff2: withBinaryFile: does not exist (No such file or directory)
    Error: pandoc document conversion failed with error 1

    I then checked the directory it was complaining about:

    > list.files("/usr/local/lib/R/site-library/fontawesome/fontawesome/css/../webfonts/")
    [1] "fa-brands-400.ttf"   "fa-brands-400.woff"  "fa-regular-400.ttf" 
    [4] "fa-regular-400.woff" "fa-solid-900.ttf"    "fa-solid-900.woff"  

    As you can see, the file fa-v4compatibility.woff2 really didn't exist. I then checked the rstudio/fontawesome to see if they were tracking the file I needed and indeed they were. So I simply installed the latest version and was good to go, problem solved.

  20. amloewi commented on Oct 8, 2023

    @amloewi

    @gorgitko I'm trying to use your solution, but the render.r I'm seeing looks very different from what's referenced here; the file I'm looking at is in rmarkdown-master/R/render.r, but it's over 1200 lines. I tried adding your code anyway, right inside of the "render" function, but it still failed in the same way. Am I looking in the right file, or does the new structure break your solution? (Or something else?)

  21. amloewi commented on Oct 8, 2023

    @amloewi

    @gorgitko I'm trying to use your solution, but the render.r I'm seeing looks very different from what's referenced here; the file I'm looking at is in rmarkdown-master/R/render.r, but it's over 1200 lines. I tried adding your code anyway, right inside of the "render" function, but it still failed in the same way. Am I looking in the right file, or does the new structure break your solution? (Or something else?)

    Apologies, actually a much dumber problem -- on mac, the file name was displayed as "x.bib" but the real name was *x.bib.txt", but that could only be seen when accessing meta-information on the file (Command I). Leaving here in case somebody else is confused into the same dumb problem.

  22. Fred-Sheppard commented on Nov 22, 2023

    @Fred-Sheppard

    In the vain of dumb problems, omitting the -o before specifying the output file will cause the same error. This one caught me out (read the docs people!)

  23. huguesmercier commented on Jul 1, 2024

    @huguesmercier

    I confirm that this bug is still present with makeForkCluster (makePSOCKcluster works fine) with the following configuration:

    Apple M3 Pro
    macOS 14.5
    R 4.3.2
    pandoc 3.1.1
    rmarkdown 2.22

    The bug was hard to pinpoint, but the "dirty" solution proposed by gorgitko, copied below, still works:

    clean_tmpfiles_mod <- function() {
      message("Calling clean_tmpfiles_mod()")
    }
    assignInNamespace("clean_tmpfiles", clean_tmpfiles_mod, ns = "rmarkdown")
    
  24. ellisifnygaard commented on Aug 7, 2025

    @ellisifnygaard

    Posting this here in the hopes others with a similar issue won't have to spend half a day troubleshooting.
    I was running Rmarkdown renders in parallel on a network-mounted Linux filesystem (Ubuntu 22.04 in a container via Posit Workbench). I kept seeing error messages like this:

    pandoc: /tmp/RtmpUDKyaM/rmarkdown-str114e8b2b374951.html: withBinaryFile: does not exist (No such file or directory)
    pandoc: /tmp/RtmpUDKyaM/rmarkdown-str114e8e2b374951.html: withBinaryFile: does not exist (No such file or directory)
    pandoc: /tmp/RtmpUDKyaM/rmarkdown-str114e7f2b374951.html: withBinaryFile: does not exist (No such file or directory)
    pandoc: /tmp/RtmpUDKyaM/rmarkdown-str114e8d2b374951.html: withBinaryFile: does not exist (No such file or directory)
    pandoc: /tmp/RtmpUDKyaM/rmarkdown-str114e802b374951.html: withBinaryFile: does not exist (No such file or directory)
    

    I had a function named render_report containing a call to rmarkdown::render which I used with foreach() followed by %dopar% to render one report per "study unit" (chromosome in my case):

    # (chr_reports is a list with one element per chromosome that contains the chromosome-specific parameters)
    status <- foreach( chr = chr_reports, .combine = c ) %dopar% {
        tryCatch( 
          expr = {
            render_report(chr)
            paste0("Chromosome ", chr$params$chr_number, " successfully rendered.")
          }
          , error = function( e ){
            paste0( "Chromosome ", chr$params$chr_number, " failed to render: "
                    , e$message)
          } )
      }
      doParallel::stopImplicitCluster()
    

    The only way I was able to ensure each render got its own directory in the temporary directory, and eliminate the pandoc errors completely, was to wrap the rmarkdown::render() code in callr::r() like so:

    render_report <- function(chr){
      # Path to the rmd file:
      rmd_path <- "path/to/rmd/file.Rmd"
      
      # Get path to folder to place the html reports in:
      reports_folder_path <- "path/to/reports/folder"
      
      # (chr is a list containing parameters etc.)
      
      callr::r(
        func = function(rmd_path, reports_folder_path, chr){
          library(rmarkdown)
          
          # Create temporary dir specific to the process:
          td <- tempfile( pattern = "tmp_" )
          dir.create( td )
          old_tmpdir <- Sys.getenv("TMPDIR")
          
          # Set new temporary dir:
          Sys.setenv(TMPDIR = td)
          
          # Change back to old temporary dir and delete temporary dir when exiting
          # function:
          on.exit({ 
            Sys.setenv(TMPDIR = old_tmpdir)
            unlink(td, recursive = TRUE)
          }, add = TRUE)
          
          # Render Rmd for chromosome number i:
          rmarkdown::render(
            input = rmd_path
            # The working directory inside the Rmd file:
            , knit_root_dir = chr$params$root_dir
            # Intermediate directory:
            , intermediates_dir = td
            # Parameters:
            , params = chr$params
            # File name of html report:
            , output_file = chr$out
            # Where to place the html report:
            , output_dir = reports_folder_path
            , quiet = TRUE
            , clean = TRUE
            # Ensure that script only used objects defined inside the Rmd file:
            , envir = new.env()
            # Override output options in the Rmd file's YAML
            , output_options = list(
              self_contained = TRUE
              , keep_md = FALSE
            )
          )
        }
        , args = list(
          chr = chr
          , rmd_path = rmd_path
          , reports_folder_path = reports_folder_path
        )
        , show = FALSE
      )
    }
    

    The initial version of render_report() without callr::r() (see below) worked fine on a virtual Windows machine, but resulted in the aforementioned pandoc errors when I ran my code on the Linux set-up.

    render_report <- function(chr){
      # Path to the rmd file:
      rmd_path <- "path/to/rmd/file.Rmd"
      
      # Get path to folder to place the html reports in:
      reports_folder_path <- "path/to/reports/folder"
      
      # Make temporary directory to serve as intermediate files directory:
      td <- tempfile()
      dir.create(td)
      
      # Render Rmd for chromosome number i:
      rmarkdown::render(
        input = rmd_path
        # The working directory inside the Rmd file:
        , knit_root_dir = chr$params$root_dir
        # Intermediate directory:
        , intermediates_dir = td
        # Parameters:
        , params = chr$params
        # File name of html report:
        , output_file = chr$out
        # Where to place the html report:
        , output_dir = reports_folder_path
        , quiet = TRUE
        # Ensure that script only used objects defined inside the Rmd file:
        , envir = new.env()
      )
    }
    
  25. yihui commented on Aug 26, 2026

    @yihui
    Collaborator

    It's almost the 7th anniversary of this issue now. I think the PR #2631 should fix it. Please try the development version of rmarkdown via

    install.packages('rmarkdown', repos = 'https://rstudio.r-universe.dev')

    Thanks everyone!

  26. added a commit that references this issue on Aug 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugtheme: pandoc

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions