I am using bookdown to build a book. Amazing tool, so thanks to Yihui.
Everytime I build the book, it is placing alot of files in my working directory that are just clutter as far as I am concerned. The offending filenames look like:
bookdown12785f3e7851, or
render12785f89239.rds
My guess is that these are cache files, but I am not sure. Any guidance on what these files are used for and how I can avoid seeing them in my working directory would be appreciated.
Thanks for the quick response. My issue is they are not automatically being cleaned up. They just accumulate.
I reinstalled bookdown, but to no avail. I know this problem did not exist initially, so I messed things up along the way.
Is there a parameter set somewhere (options() or a yml file) that requests to keep these files? I feel I might have requested temp files be kept during a debugging mission and have now forgot how to undo it.
Pull request complete. I have created a solution that solves my problem. Basically, add recursive = TRUE to the unlink function call. You can see the problem, as it exists on my machine, reproduced using the code below. I wish I knew exactly why the recursive = TRUE argument must be passed to unlink (because it seems like it should work without that argument), but I do not. That being said, I think the fix is low-risk as other unlink calls in the render.R file already had this setting.
## mimic creation of tempFile name as is done in bookdown::render.R
tempFile = tempfile('render', '.', '.rds')
print(tempFile)
file.exists(tempFile) ### returns FALSE, nothing written to file
## write something to file
writeLines("This is a temp file", con = tempFile)
file.exists(tempFile) ### returns TRUE
## use unlink with default value of recursive = FALSE
unlink(tempFile)
## check if file exists
file.exists(tempFile) ### returns TRUE, file still exists!
## use unlink with default value of recursive = FALSE
unlink(tempFile, recursive = TRUE)
## check if file exists
file.exists(tempFile) ### returns FALSE, finally got rid of it
## I do not know why this option needs to be TRUE as it does not
## seem we are doing a recursive search down a directory tree.
## My only guess is it has something to to with the path specification
## as tempFile = ".\\render2b885fcas674b.rds" and I am not familiar
## with the ".\\" notation.