rmarkdown icon indicating copy to clipboard operation
rmarkdown copied to clipboard

Tex intermediate files are written in input directory even if output file is in another dir, or intermediates file is set

Open cderv opened this issue 4 years ago • 5 comments

This is more like a note for future us to question the current behavior.

Currently, it seems that the aux files are written to the working directory (from which latexmk is run) and not in the same directory as the input tex file.

This was notice on a server with special access rights by a user on community, and I find it is not obvious. I would have expect to have the files produce by latex conversion to the same dir as tex input or pdf output. Or at least when used with rmarkdown in the intermediate_dir.

I open this issue in rmarkdown not tinytex because the behavior was found while using rmarkdown. I can reopen in tinytex if this is more scoped to there. From tinytex point of view: Auxiliary files are written in current working dir, not in the input directory unless tinytex.output_dir is set with engine_args containing --output-directory=output_dir.

Example

dir.create(tmp_dir <- tempfile())
owd <- setwd(tmp_dir)
xfun::write_utf8(c(
  "---",
  "title: test",
  "---",
  "",
  "# A header",
  ""
), "test.Rmd")
dir.create("temp")
dir.create("out")
options(tinytex.clean = FALSE)
rmarkdown::render("test.Rmd", "pdf_document", 
                  output_options = list(keep_tex = TRUE),
                  output_file = "out/test.pdf",
                  intermediates_dir = "temp",
                  quiet = TRUE)
fs::dir_tree()
#> .
#> +-- out
#> |   +-- test.pdf
#> |   \-- test.tex
#> +-- temp
#> +-- test.aux
#> +-- test.log
#> +-- test.out
#> \-- test.Rmd
setwd(owd)
unlink(tmp_dir, recursive = TRUE)

Created on 2020-12-09 by the reprex package (v0.3.0.9001)

cderv avatar Dec 09 '20 09:12 cderv

Closing this one will close #1615

cderv avatar Jan 14 '21 16:01 cderv

Came across this issue as well. From Shiny I am trying to render markdowns outside application folders, to avoid giving Shiny write permissions to any folders within application. Would be nice if rendering could work, without render user having write access to Rmd folder.

stiberger avatar May 21 '21 09:05 stiberger

@stiberger this is also for PDF document, right ?

cderv avatar May 21 '21 09:05 cderv

Is there an update to this issue? I've also come across it in the context of rendering Rmd in a directory with read-only access. It would be nice to have an argument specifying the folder where .log and related documents will be processed.

squirrellina avatar Feb 24 '22 16:02 squirrellina

No update yet to change the behavior - it still open. When this will be dealt with, we will update here.

Current workaround is to copy Rmd file and resources in a place with write access (like Rmd templates in package installation folder are copied to user's project). I believe rmarkdown assumes in several places that working directory is writable and this issue may not be the only limitation. Do not hesitate to add a 👍 to the main post above to move this up among the topic to tackle next. thanks !

cderv avatar Feb 28 '22 10:02 cderv