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

render with run_pandoc = FALSE deletes markdown file by default #1812

Closed
3 tasks done
BrianDiggs opened this issue Apr 28, 2020 · 2 comments
Closed
3 tasks done

render with run_pandoc = FALSE deletes markdown file by default #1812

BrianDiggs opened this issue Apr 28, 2020 · 2 comments
Labels
bug an unexpected problem or unintended behavior

Comments

@BrianDiggs
Copy link


By filing an issue to this repo, I promise that

  • I have fully read the issue guide at https://yihui.org/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.

Summary

When running rmarkdown::render with the run_pandoc = FALSE option, the markdown file that is generated, and the name of which is returned, is deleted in the clean up process. To keep the file, the option clean = FALSE must also be supplied which keeps more than the final markdown file.

Reproducible example

ex <- system.file("rmarkdown", "templates", "html_vignette", "skeleton", "skeleton.Rmd", package = "rmarkdown")

privatedir <- tempfile("PandocExample")
dir.create(privatedir)
setwd(privatedir)
file.copy(ex, ".")
list.files()

rmarkdown::render("skeleton.Rmd", run_pandoc = FALSE)
list.files()
rmarkdown::render("skeleton.Rmd", run_pandoc = FALSE, clean = FALSE)
list.files()
rmarkdown::render("skeleton.Rmd", run_pandoc = TRUE)
list.files()

Description of example and expected and actual output

As this bug report involves the creation of files in the RMarkdown render process, first create a controlled environment. Use the skeleton.Rmd which comes with rmarkdown as the example file to render. Use tempfile to get a unique, writable, unused directory that will work for everyone. Create that directory, set the working directory to it, and copy the skeleton.Rmd file to it. At this point, list.files() should only return "skeleton.Rmd".

The first invocation of rmarkdown::render has the run_pandoc = FALSE argument. The output of that (with irrelevant knitting details removed) is

> rmarkdown::render("skeleton.Rmd", run_pandoc = FALSE)


processing file: skeleton.Rmd
[…]
output file: skeleton.knit.md

[1] "skeleton.knit.md"
attr(,"knit_meta")
list()
attr(,"intermediates")
[1] "skeleton.knit.md" "skeleton.utf8.md" "skeleton_files"  
> list.files()
[1] "skeleton.Rmd"

rmarkdown::render correctly returns "skeleton.knit.md" as the name of the knitted, but not pandoced, file. However, the file itself is not in the directory as seen by the output of list.files(). The expected behavior is that "skeleton.knit.md" would be present in the directory.

Invoking rmarkdown::render with both run_pandoc = FALSE and clean = FALSE gives identical printed output for the rmarkdown::render function, but list.files() now gives

> list.files()
[1] "skeleton.knit.md" "skeleton.Rmd"     "skeleton.utf8.md" "skeleton_files"

This behaves as expected and appears to be the only way to get the "skeleton.knit.md" file to remain present after rmarkdown::render() is run.

The final invocation just demonstrates that when pandoc is run, the expected final output file ("skeleton.html") is preserved.

Discussion

When rmarkdown::render() is invoked with the run_pandoc = FALSE option, the markdown file created is not an intermediate file, but rather the expected, final output file. clean = FALSE should not be required to keep that file around as it keeps other files as well.

Session Info

> xfun::session_info("rmarkdown")
R version 3.6.1 (2019-07-05)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 17763), RStudio 1.2.1335

Locale:
  LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252   
  LC_MONETARY=English_United States.1252 LC_NUMERIC=C                          
  LC_TIME=English_United States.1252    

Package version:
  base64enc_0.1.3 digest_0.6.25   evaluate_0.14   glue_1.4.0      graphics_3.6.1  grDevices_3.6.1
  highr_0.8       htmltools_0.4.0 jsonlite_1.6.1  knitr_1.28      magrittr_1.5    markdown_1.1   
  methods_3.6.1   mime_0.9        Rcpp_1.0.4.6    rlang_0.4.5     rmarkdown_2.1   stats_3.6.1    
  stringi_1.4.6   stringr_1.4.0   tinytex_0.22    tools_3.6.1     utils_3.6.1     xfun_0.13      
  yaml_2.2.1     

Pandoc version: 2.7.3

This is not the most recent version of R, but as I do not have the ability to install software as it is a work machine, it is what is available. I do not believe that anything in base R should affect this behavior. Installing the latest version of rmarkdown from GitHub using remotes::install_github('rstudio/rmarkdown', upgrade = TRUE) does not change any outputs or side effects; the same unexpected behavior is there.

@yihui yihui added the bug an unexpected problem or unintended behavior label May 29, 2020
@yihui yihui closed this as completed in d98431f May 29, 2020
@yihui
Copy link
Member

yihui commented May 29, 2020

Should be fixed now. Thanks for the report!

yihui added a commit that referenced this issue May 30, 2020
…le and associated figure files from the list of intermediate files, so they won't be cleaned up
yihui added a commit that referenced this issue May 30, 2020
…le and associated figure files from the list of intermediate files, so they won't be cleaned up
@github-actions
Copy link

github-actions bot commented Dec 1, 2020

This old thread has been automatically locked. If you think you have found something related to this, please open a new issue by following the issue guide (https://yihui.org/issue/), and link to this old issue if necessary.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 1, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

2 participants