Skip to content

rmarkdown::render() corrupts input file #2534

@J-Moravec

Description

@J-Moravec

Issue:

Made a typo and instead of rmarkdown::render("report.rmd") wrote rmarkdown::render("report.rds"). To my surprise, rmarkdown finished without error, but the rds file was mangled. This shouldn't happen.

Why this is an issue:

Somewhere in the pipeline, the input file is being modified. This means that potentially, the call of rmarkdown::render(input) can corrupt the input file. This breaks the assumption of the call being safe.

MRE:

saveRDS("test", "test.rds")
rmarkdown::render("test.rds") # no error
readRDS("test.rds") # error

Reproduced on both the latest cran and the development version of rmarkdown.

Output of xfun::session_info("rmarkdown")

R version 4.1.2 (2021-11-01)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 22.04.3 LTS

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

Package version:
  base64enc_0.1.3   bslib_0.6.1       cachem_1.0.8      cli_3.6.2        
  digest_0.6.34     ellipsis_0.3.2    evaluate_0.23     fastmap_1.1.1    
  fontawesome_0.5.2 fs_1.6.3          glue_1.7.0        graphics_4.1.2   
  grDevices_4.1.2   highr_0.10        htmltools_0.5.7   jquerylib_0.1.4  
  jsonlite_1.8.8    knitr_1.45        lifecycle_1.0.4   memoise_2.0.1    
  methods_4.1.2     mime_0.12         R6_2.5.1          rappdirs_0.3.3   
  rlang_1.1.3       rmarkdown_2.25.2  sass_0.4.8        stats_4.1.2      
  tinytex_0.49      tools_4.1.2       utils_4.1.2       xfun_0.41        
  yaml_2.3.8       

Pandoc version: 2.9.2.1

Metadata

Metadata

Assignees

Labels

bugan unexpected problem or unintended behavior

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions