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

Make intermediates_dir explicit earlier to fix 1980 #1982

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
rmarkdown 2.7
================================================================================

- Fix intermediate files being created at the current directory instead of the input directory when the input file name contains shell characters and `render(intermediates_dir = NULL)` (thanks, @atusy, #1982).

rmarkdown 2.6
================================================================================
Expand Down
8 changes: 2 additions & 6 deletions R/render.R
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,8 @@ render <- function(input,
if (!dir_exists(intermediates_dir))
dir.create(intermediates_dir, recursive = TRUE)
intermediates_dir <- normalize_path(intermediates_dir)
} else {
intermediates_dir <- normalize_path(dirname(input))
}
intermediates_loc <- function(file) {
if (is.null(intermediates_dir))
Expand Down Expand Up @@ -364,12 +366,6 @@ render <- function(input,
file.copy(input, input_no_shell_chars, overwrite = TRUE)
intermediates <- c(intermediates, input_no_shell_chars)
input <- input_no_shell_chars

# if an intermediates directory wasn't explicit before, make it explicit now
if (is.null(intermediates_dir)) {
intermediates_dir <-
dirname(normalize_path(input_no_shell_chars))
}
}

# never use the original input directory as the intermediate directory,
Expand Down