Closed NelleV closed 6 years ago
@NelleV Output directories will be created so long as there are write permissions in parent dirs. Are we asking for a check on whether new dirs can be created due to the permissions issues (and if they can't be created, fail fast)?
BTW I've had this exact issue in the past, where I would set up a render()
though cron but the output folder (or a parent, if it was new) didn't have write permissions. The workaround is that you would pre-plan this and use chmod as necessary.
@rich-iannone I just created a minimal repro:
test_output_file = function() {
d = tempfile()
dir.create(d)
owd = setwd(d)
on.exit({
setwd(owd)
unlink(d, recursive = TRUE)
}, add = TRUE)
writeLines('hello world', 'foo.Rmd')
rmarkdown::render('foo.Rmd', output_file = 'does/not/exist/bar.html')
}
test_output_file()
Output:
processing file: foo.Rmd
|.................................................................| 100%
ordinary text without R code
output file: foo.knit.md
/Applications/RStudio.app/Contents/MacOS/pandoc/pandoc +RTS -K512m -RTS foo.utf8.md --to html4 --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash+smart --output does/not/exist/bar.html --email-obfuscation none --self-contained --standalone --section-divs --template /Users/yihui/R/rmarkdown/rmd/h/default.html --no-highlight --variable highlightjs=1 --variable 'theme:bootstrap' --include-in-header /var/folders/8r/zh8x49md6vsgskh23jrmy7p80000gn/T//RtmpPkWF5w/rmarkdown-str11fff3a56ed55.html --mathjax --variable 'mathjax-url:https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML' --metadata pagetitle=foo.utf8.md
pandoc: does/not/exist/bar.html: openFile: does not exist (No such file or directory)
Error: pandoc document conversion failed with error 1
Okay, that totally makes it clear (I thought otherwise :\ ). I'll have a proposed fix for this soon.
This has been addressed in PR #1410
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.
Right now, Rmardown compiles Rmd files, and then moves the file to the wished filename. It thus fails after compiling the whole document if the output_file's directory do not exist.
It should be fairly straightforward to do an early check, to avoid the compilation to fail at the very last moment.