Skip to content

Commit 9b314ce

Browse files
committed
Don't use withr and pass env to the processx call directly
1 parent 86ead03 commit 9b314ce

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

DESCRIPTION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ Imports:
3030
rstudioapi,
3131
tools,
3232
utils,
33-
withr,
3433
xfun,
3534
yaml (>= 2.3.10)
3635
Suggests:
@@ -54,7 +53,8 @@ Suggests:
5453
thematic,
5554
tidyverse,
5655
tinytable,
57-
whoami
56+
whoami,
57+
withr
5858
VignetteBuilder:
5959
quarto
6060
Config/testthat/edition: 3

R/quarto.R

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,18 +133,32 @@ quarto_run <- function(
133133
...,
134134
.call = rlang::caller_env()
135135
) {
136+
# To store any environment variables to pass to the process
137+
custom_env <- NULL
138+
136139
# This is required due to a bug in QUARTO CLI, fixed only in 1.8+
137140
# https://github.com/quarto-dev/quarto-cli/pull/12887
138-
custom_env <- NULL
139141
if (!quarto_available(min = "1.8.13")) {
140-
custom_env <- c("current", QUARTO_R = R.home("bin"))
142+
custom_env <- c(custom_env, QUARTO_R = R.home("bin"))
141143
}
144+
145+
# handle session .libpaths() for background session
146+
# It needs to be passed if .libPaths() was modified in the current R session
147+
# (e.g. to install dev package in a temporary library)
142148
opt_in_libpath <- getOption("quarto.use_libpaths", TRUE)
143149
if (isTRUE(opt_in_libpath) && !is.null(libpaths)) {
144-
withr::local_envvar(list(
150+
custom_env <- c(
151+
custom_env,
145152
R_LIBS = paste(libpaths, collapse = .Platform$path.sep)
146-
))
153+
)
147154
}
155+
156+
# This is required because `"current"` only is not supported by processx
157+
# FIXME: https://github.com/r-lib/processx/issues/399
158+
if (!is.null(custom_env)) {
159+
custom_env <- c("current", custom_env)
160+
}
161+
148162
res <- withCallingHandlers(
149163
processx::run(
150164
quarto_bin,

0 commit comments

Comments
 (0)