# What?

I'd like Quarto to create _all_ temporary/intermediate files in the given subdirectory of the project root (or `/tmp`, or another user-provided directory). By "intermediate files" I mean all files that Quarto manages itself: `.aux`, `.tex`, `.log`, the intermediate `.pdf`, the `.md` generated from the `.qmd` and so on.

I'd like to write something like this in the frontmatter:

```
project:
  output-temp-dir: temporary_files
  output-dir: out
```

This would make Quarto write stuff _only_ to `output-dir` and `output-temp-dir` and nowhere else. Currently, like knitr/bookdown/Rmarkdown, Quarto will write temporary files to the current directory.

# Why?

1. I created a Quarto project with the default file `report.qmd` (Quarto markdown).
2. I tried editing it in RStudio but didn't like it, so I exited RStudio _without closing the file_.
3. I switched to Zettlr, but it couldn't see the file, so I renamed it to `report.md` (regular Markdown). Now it worked and I continued working on `report.md` for a week in Zettlr.
4. Rendering the file with `quarto render --to pdf` worked great. I simply had to put `project: render: report.md` in `_quarto.yml`.
5. Today I started RStudio and apparently saved `report.qmd` (Quarto markdown!), so that it appeared in my project. Now I had _both_ `report.md` with a week's worth of work and the almost empty `report.qmd`. For whatever reason (again, probably RStudio re-saved the old version of `_quarto.yml` too) the line `project: render: report.md` got changed to `.qmd`.
6. I finally finished my work on `report.md` and rendered it: `quarto render --to pdf`.
7. `report.md` was __GONE__ and `report.pdf` contained whatever nonsense `report.qmd` had.
8. I attempted to recover `report.md` with various tools, but to no avail.

It looks like in the process of analyzing `report.qmd`, Quarto deleted the "old" `report.md`, created a _new_ `report.md` with the processed contents of `report.qmd`, merrily created the PDF from that MD file and then deleted `report.md` as an artefact of processing `report.qmd`.

Now all my work is gone, and it's kinda my fault because I named my file `report.md` and had a `report.qmd` alongside it. Also, I could've easily used version control, but deliberately chose not to since I was too lazy to set it up. Which turned out to be a stupid decision. It's also Quarto's fault: it could've looked at the modification dates, wondered why the "temporary" file `report.md` is _much newer_ than the "original" `report.qmd` and asked me for permission to overwrite `report.md`.

---------

I would like Quarto (and knitr/bookdown/RMarkdown/whatever) to do its processing and creating temporary files __in `/tmp`__, because that's where _temporary_ files are supposed to go. Or in `output-temp-dir: temporary_files`, as suggested earlier, so that the user can control where the temporary files are going. But _not_ in my working directory, where it can overwrite any important `.md` file I spent a week working on.

That would solve all such problems: I write my MD files in my project's directory, Quarto copies everything to `/tmp/whatevergibberish`, processes it and puts the output into `output-dir`. If the project's settings (or the frontmatter) require to save the `.tex` file, then copy it into the output directory as well. This way, the user doesn't have to worry about the processing done by Quarto. They also don't need to worry about Quarto overwriting their `.md` files.

Also, all output _only_ goes to `output-dir` and Quarto _never ever writes to the directory with the user's source files_ or any other directory besides those marked as `output-`: `output-temp-dir` and `output-dir`.
2022-08-03T19:16:38Z
ForceBru
Future
open
[Feature request] Can Quarto please create_all_ temporary files _not_ in the same directory with my source files?
https://github.com/quarto-dev/quarto-cli/issues/1666