From 1002b5312158d8af9ecaf82e616d99af832a0a28 Mon Sep 17 00:00:00 2001 From: Christophe Dervieux Date: Mon, 20 Oct 2025 15:33:10 +0200 Subject: [PATCH 01/15] Reformat with latest air --- R/preview.R | 2 +- tests/testthat/_snaps/spin/spin_preamble-custom-preamble.R | 2 +- tests/testthat/_snaps/spin/spin_preamble-custom-title.R | 2 +- tests/testthat/_snaps/spin/spin_preamble-empty.R | 3 +-- tests/testthat/_snaps/spin/spin_preamble-preamble-title.R | 2 +- tests/testthat/_snaps/spin/spin_preamble-title-override.R | 2 +- tests/testthat/_snaps/spin/spin_preamble.R | 2 +- tests/testthat/_snaps/utils-extract/purl.R | 4 +--- tests/testthat/resources/purl-r-ojs.R | 2 +- 9 files changed, 9 insertions(+), 12 deletions(-) diff --git a/R/preview.R b/R/preview.R index 203f01bc..c36cc9f9 100644 --- a/R/preview.R +++ b/R/preview.R @@ -24,7 +24,7 @@ #' @param quiet Suppress warning and other messages, from R and also Quarto CLI #' (i.e `--quiet` is passed as command line) #' -#' @return The URL of the preview server (invisibly). This can be used to +#' @return The URL of the preview server (invisibly). This can be used to #' programmatically access the server location, for example to take screenshots #' with webshot2 or pass to other automation tools. #' diff --git a/tests/testthat/_snaps/spin/spin_preamble-custom-preamble.R b/tests/testthat/_snaps/spin/spin_preamble-custom-preamble.R index 57b52142..e2b5cf4b 100644 --- a/tests/testthat/_snaps/spin/spin_preamble-custom-preamble.R +++ b/tests/testthat/_snaps/spin/spin_preamble-custom-preamble.R @@ -3,7 +3,7 @@ #' author: John Doe #' format: html #' --- -#' +#' library(ggplot2) plot(1:10) diff --git a/tests/testthat/_snaps/spin/spin_preamble-custom-title.R b/tests/testthat/_snaps/spin/spin_preamble-custom-title.R index 26d6fcaf..f30743bd 100644 --- a/tests/testthat/_snaps/spin/spin_preamble-custom-title.R +++ b/tests/testthat/_snaps/spin/spin_preamble-custom-title.R @@ -1,7 +1,7 @@ #' --- #' title: Custom Analysis #' --- -#' +#' x <- 1 y <- 2 diff --git a/tests/testthat/_snaps/spin/spin_preamble-empty.R b/tests/testthat/_snaps/spin/spin_preamble-empty.R index 240b926b..5aec2cdf 100644 --- a/tests/testthat/_snaps/spin/spin_preamble-empty.R +++ b/tests/testthat/_snaps/spin/spin_preamble-empty.R @@ -1,6 +1,5 @@ #' --- #' title: report #' --- -#' - +#' diff --git a/tests/testthat/_snaps/spin/spin_preamble-preamble-title.R b/tests/testthat/_snaps/spin/spin_preamble-preamble-title.R index e3054fae..15f39270 100644 --- a/tests/testthat/_snaps/spin/spin_preamble-preamble-title.R +++ b/tests/testthat/_snaps/spin/spin_preamble-preamble-title.R @@ -2,6 +2,6 @@ #' title: Preamble Title #' author: Jane Doe #' --- -#' +#' x <- 1 diff --git a/tests/testthat/_snaps/spin/spin_preamble-title-override.R b/tests/testthat/_snaps/spin/spin_preamble-title-override.R index 81757d40..6058dbc2 100644 --- a/tests/testthat/_snaps/spin/spin_preamble-title-override.R +++ b/tests/testthat/_snaps/spin/spin_preamble-title-override.R @@ -2,6 +2,6 @@ #' title: Override Title #' author: John Doe #' --- -#' +#' x <- 1 diff --git a/tests/testthat/_snaps/spin/spin_preamble.R b/tests/testthat/_snaps/spin/spin_preamble.R index c2c8b203..1b7568f4 100644 --- a/tests/testthat/_snaps/spin/spin_preamble.R +++ b/tests/testthat/_snaps/spin/spin_preamble.R @@ -1,7 +1,7 @@ #' --- #' title: report #' --- -#' +#' x <- 1 y <- 2 diff --git a/tests/testthat/_snaps/utils-extract/purl.R b/tests/testthat/_snaps/utils-extract/purl.R index 8bc32a62..48c0bff6 100644 --- a/tests/testthat/_snaps/utils-extract/purl.R +++ b/tests/testthat/_snaps/utils-extract/purl.R @@ -2,7 +2,7 @@ #' title: Purl Test Document #' format: html #' --- -#' +#' #| label: my-label #| echo: false @@ -15,5 +15,3 @@ cat("more") #| eval: false # # This code should not run. # 1 + a - - diff --git a/tests/testthat/resources/purl-r-ojs.R b/tests/testthat/resources/purl-r-ojs.R index 73742879..eb732e6f 100644 --- a/tests/testthat/resources/purl-r-ojs.R +++ b/tests/testthat/resources/purl-r-ojs.R @@ -2,5 +2,5 @@ #' title: Purl Test Document #' format: html #' --- -#' +#' From 66c284667234f5c162ec5c27fce5fcffe7008f31 Mon Sep 17 00:00:00 2001 From: Christophe Dervieux Date: Mon, 17 Mar 2025 14:53:31 +0100 Subject: [PATCH 02/15] Pass `.libPaths()` as R_LIBS to quarto subprocess --- DESCRIPTION | 4 ++-- NEWS.md | 2 ++ R/quarto.R | 7 +++++++ R/render.R | 7 ++++++- man/quarto_render.Rd | 6 ++++++ tests/testthat/test-quarto.R | 23 +++++++++++++++++++++++ 6 files changed, 46 insertions(+), 3 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index d560673c..e25cc263 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -30,6 +30,7 @@ Imports: rstudioapi, tools, utils, + withr, xfun, yaml (>= 2.3.10) Suggests: @@ -53,8 +54,7 @@ Suggests: thematic, tidyverse, tinytable, - whoami, - withr + whoami VignetteBuilder: quarto Config/testthat/edition: 3 diff --git a/NEWS.md b/NEWS.md index 7742812d..fa03ec7d 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,7 @@ # quarto (development version) +- `.libPaths()` from the calling R session will now be passed by default to all call to quarto as a subprocess. This should solve issue with **pkgdown** or when building vignettes (thanks, ) + # quarto 1.5.1 - Make sure tests pass on CRAN checks even when Quarto is not installed by adding a gihub action to test when no quarto is available. Also fix tests that were diff --git a/R/quarto.R b/R/quarto.R index c0e7b8f5..085c084f 100644 --- a/R/quarto.R +++ b/R/quarto.R @@ -128,6 +128,7 @@ quarto_run <- function( args = character(), quarto_bin = find_quarto(), echo = FALSE, + libpaths = .libPaths(), echo_cmd = getOption("quarto.echo_cmd", FALSE), ..., .call = rlang::caller_env() @@ -138,6 +139,12 @@ quarto_run <- function( if (!quarto_available(min = "1.8.13")) { custom_env <- c("current", QUARTO_R = R.home("bin")) } + opt_in_libpath <- getOption("quarto.use_libpaths", TRUE) + if (isTRUE(opt_in_libpath) && !is.null(libpaths)) { + withr::local_envvar(list( + R_LIBS = paste(libpaths, collapse = .Platform$path.sep) + )) + } res <- withCallingHandlers( processx::run( quarto_bin, diff --git a/R/render.R b/R/render.R index 006b5bf5..4836e08d 100644 --- a/R/render.R +++ b/R/render.R @@ -51,6 +51,10 @@ #' advanced usage and useful for CLI arguments which are not yet mirrored in a #' dedicated parameter of this \R function. See `quarto render --help` for options. #' @param pandoc_args Additional command line arguments to pass on to Pandoc. +#' @param libpaths A character vector of library paths to use for the R session run by Quarto. +#' If `NULL`, no library paths will be pass to quarto subprocess and defaults R one will be used. +#' Setting `options(quarto.use_libpaths = FALSE)` will disable this behavior and +#' never pass library paths to quarto subprocess. #' @param as_job Render as an RStudio background job. Default is `"auto"`, #' which will render individual documents normally and projects as #' background jobs. Use the `quarto.render_as_job` \R option to control @@ -95,6 +99,7 @@ quarto_render <- function( profile = NULL, quarto_args = NULL, pandoc_args = NULL, + libpaths = .libPaths(), as_job = getOption("quarto.render_as_job", "auto") ) { # get quarto binary @@ -222,7 +227,7 @@ quarto_render <- function( } # run quarto - quarto_run(args, echo = TRUE, quarto_bin = quarto_bin) + quarto_run(args, echo = TRUE, quarto_bin = quarto_bin, libpaths = libpaths) # no return value invisible(NULL) diff --git a/man/quarto_render.Rd b/man/quarto_render.Rd index 7b2e768b..c728ee99 100644 --- a/man/quarto_render.Rd +++ b/man/quarto_render.Rd @@ -24,6 +24,7 @@ quarto_render( profile = NULL, quarto_args = NULL, pandoc_args = NULL, + libpaths = .libPaths(), as_job = getOption("quarto.render_as_job", "auto") ) } @@ -93,6 +94,11 @@ dedicated parameter of this \R function. See \verb{quarto render --help} for opt \item{pandoc_args}{Additional command line arguments to pass on to Pandoc.} +\item{libpaths}{A character vector of library paths to use for the R session run by Quarto. +If \code{NULL}, no library paths will be pass to quarto subprocess and defaults R one will be used. +Setting \code{options(quarto.use_libpaths = FALSE)} will disable this behavior and +never pass library paths to quarto subprocess.} + \item{as_job}{Render as an RStudio background job. Default is \code{"auto"}, which will render individual documents normally and projects as background jobs. Use the \code{quarto.render_as_job} \R option to control diff --git a/tests/testthat/test-quarto.R b/tests/testthat/test-quarto.R index e4d7aab7..ad35040c 100644 --- a/tests/testthat/test-quarto.R +++ b/tests/testthat/test-quarto.R @@ -157,3 +157,26 @@ test_that("quarto_available()", { regexp = "Minimum version expected is 1.9.5" ) }) + +test_that("quarto sees same libpaths as main process", { + skip_if_no_quarto() + skip_on_cran() + qmd <- local_qmd_file(c("```{r}", "#| echo: false", ".libPaths()", "```")) + tmp_lib <- withr::local_tempdir("tmp_libpath") + withr::local_libpaths(tmp_lib, action = "prefix") + withr::local_dir(dirname(qmd)) + out <- "out.md" + # .libPaths() is known in Quarto render + quarto_render(qmd, output_format = "gfm", output_file = out, quiet = TRUE) + expect_match(readLines(out), basename(tmp_lib), all = FALSE, fixed = TRUE) + # Opting-out globally + withr::with_options( + list(quarto.use_libpaths = FALSE), + quarto_render(qmd, output_format = "gfm", output_file = out, quiet = TRUE) + ) + expect_no_match(readLines(out), basename(tmp_lib), fixed = TRUE) + # Opting-out at command + quarto_render(qmd, output_format = "gfm", output_file = out, quiet = TRUE, libpaths = NULL) + expect_no_match(readLines(out), basename(tmp_lib), fixed = TRUE) + +}) \ No newline at end of file From 1a9e74cb0a26680c5256d23ee6b4c49f3b92e8bc Mon Sep 17 00:00:00 2001 From: Christophe Dervieux Date: Mon, 17 Mar 2025 16:48:28 +0100 Subject: [PATCH 03/15] Use helper in tests --- tests/testthat/test-quarto.R | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/testthat/test-quarto.R b/tests/testthat/test-quarto.R index ad35040c..e00ec3da 100644 --- a/tests/testthat/test-quarto.R +++ b/tests/testthat/test-quarto.R @@ -167,16 +167,16 @@ test_that("quarto sees same libpaths as main process", { withr::local_dir(dirname(qmd)) out <- "out.md" # .libPaths() is known in Quarto render - quarto_render(qmd, output_format = "gfm", output_file = out, quiet = TRUE) - expect_match(readLines(out), basename(tmp_lib), all = FALSE, fixed = TRUE) + out <- .render_and_read(qmd, output_format = "gfm") + expect_match(out, basename(tmp_lib), all = FALSE, fixed = TRUE) # Opting-out globally withr::with_options( list(quarto.use_libpaths = FALSE), - quarto_render(qmd, output_format = "gfm", output_file = out, quiet = TRUE) + out <- .render_and_read(qmd, output_format = "gfm") ) - expect_no_match(readLines(out), basename(tmp_lib), fixed = TRUE) + expect_no_match(out, basename(tmp_lib), fixed = TRUE) # Opting-out at command - quarto_render(qmd, output_format = "gfm", output_file = out, quiet = TRUE, libpaths = NULL) - expect_no_match(readLines(out), basename(tmp_lib), fixed = TRUE) + out <- .render_and_read(qmd, output_format = "gfm", libpaths = NULL) + expect_no_match(out, basename(tmp_lib), fixed = TRUE) }) \ No newline at end of file From 92e6efc07911e2976e9b8d9187852891affb1ed4 Mon Sep 17 00:00:00 2001 From: Christophe Dervieux Date: Mon, 17 Mar 2025 20:09:37 +0100 Subject: [PATCH 04/15] Show quarto output in CI --- .github/workflows/R-CMD-check.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index ac77d202..253faa18 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -74,6 +74,8 @@ jobs: install-pandoc: false - uses: r-lib/actions/check-r-package@v2 + env: + QUARTO_R_QUIET: FALSE with: upload-snapshots: true args: ${{ format('c("--no-manual", "--as-cran"{0})', format('{0}', matrix.config.quarto) == 'false' && ',"--ignore-vignettes"' || '') }} From dd169c66efd482c4fe7f33e685f5bee8b40f832a Mon Sep 17 00:00:00 2001 From: Christophe Dervieux Date: Mon, 17 Mar 2025 20:33:27 +0100 Subject: [PATCH 05/15] Unset QUARTO_R_QUIET in test that are impacted by it --- tests/testthat/test-quarto-args.R | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/testthat/test-quarto-args.R b/tests/testthat/test-quarto-args.R index 2ce099c2..071f8bb8 100644 --- a/tests/testthat/test-quarto-args.R +++ b/tests/testthat/test-quarto-args.R @@ -24,6 +24,7 @@ test_that("create quiete arg", { }) test_that("quarto.quiet options takes over", { + withr::local_envvar(list(QUARTO_R_QUIET = NA)) expect_identical(is_quiet(TRUE), TRUE) expect_identical(is_quiet(FALSE), FALSE) expect_identical(is_quiet(NA), FALSE) @@ -63,6 +64,7 @@ test_that("R_QUARTO_QUIET options takes over", { }) test_that("quarto.quiet options takes over R_QUARTO_QUIET", { + withr::local_envvar(list(R_QUARTO_QUIET = NA)) withr::with_options(list(quarto.quiet = TRUE), { withr::with_envvar(list(R_QUARTO_QUIET = FALSE), { expect_identical(is_quiet(TRUE), TRUE) From ed1daab5f653a62808626fd2f8c27afe7d3731cb Mon Sep 17 00:00:00 2001 From: Christophe Dervieux Date: Mon, 17 Mar 2025 20:46:47 +0100 Subject: [PATCH 06/15] Also remove env var in this test --- tests/testthat/test-render.R | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/testthat/test-render.R b/tests/testthat/test-render.R index dee7a2ec..b6e25740 100644 --- a/tests/testthat/test-render.R +++ b/tests/testthat/test-render.R @@ -54,6 +54,7 @@ test_that("metadata-file and metadata are merged in quarto_render", { test_that("quarto_args in quarto_render", { skip_if_no_quarto() + withr::local_envvar(list(QUARTO_R_QUIET = NA)) qmd <- local_qmd_file(c("content")) local_quarto_run_echo_cmd() withr::local_dir(dirname(qmd)) From 86ead034ea951e94cee40c609c698a74732d90dc Mon Sep 17 00:00:00 2001 From: Christophe Dervieux Date: Thu, 5 Jun 2025 16:02:09 +0200 Subject: [PATCH 07/15] reformat using air --- R/render.R | 6 +++--- tests/testthat/test-quarto.R | 22 ++++++++++++++++++++++ 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/R/render.R b/R/render.R index 4836e08d..8c17e6bd 100644 --- a/R/render.R +++ b/R/render.R @@ -51,9 +51,9 @@ #' advanced usage and useful for CLI arguments which are not yet mirrored in a #' dedicated parameter of this \R function. See `quarto render --help` for options. #' @param pandoc_args Additional command line arguments to pass on to Pandoc. -#' @param libpaths A character vector of library paths to use for the R session run by Quarto. -#' If `NULL`, no library paths will be pass to quarto subprocess and defaults R one will be used. -#' Setting `options(quarto.use_libpaths = FALSE)` will disable this behavior and +#' @param libpaths A character vector of library paths to use for the R session run by Quarto. +#' If `NULL`, no library paths will be pass to quarto subprocess and defaults R one will be used. +#' Setting `options(quarto.use_libpaths = FALSE)` will disable this behavior and #' never pass library paths to quarto subprocess. #' @param as_job Render as an RStudio background job. Default is `"auto"`, #' which will render individual documents normally and projects as diff --git a/tests/testthat/test-quarto.R b/tests/testthat/test-quarto.R index e00ec3da..d248b2fa 100644 --- a/tests/testthat/test-quarto.R +++ b/tests/testthat/test-quarto.R @@ -124,6 +124,28 @@ test_that("quarto.quiet options controls echo and overwrite function argument", }) }) +test_that("quarto sees same libpaths as main process", { + skip_if_no_quarto() + skip_on_cran() + qmd <- local_qmd_file(c("```{r}", "#| echo: false", ".libPaths()", "```")) + tmp_lib <- withr::local_tempdir("tmp_libpath") + withr::local_libpaths(tmp_lib, action = "prefix") + withr::local_dir(dirname(qmd)) + out <- "out.md" + # .libPaths() is known in Quarto render + out <- .render_and_read(qmd, output_format = "gfm") + expect_match(out, basename(tmp_lib), all = FALSE, fixed = TRUE) + # Opting-out globally + withr::with_options( + list(quarto.use_libpaths = FALSE), + out <- .render_and_read(qmd, output_format = "gfm") + ) + expect_no_match(out, basename(tmp_lib), fixed = TRUE) + # Opting-out at command + out <- .render_and_read(qmd, output_format = "gfm", libpaths = NULL) + expect_no_match(out, basename(tmp_lib), fixed = TRUE) +}) + test_that("quarto_available()", { expect_error( quarto_available("1.5", "1.4"), From 9b314ce36b731b0b83d45f4a4ff777a0241c7b68 Mon Sep 17 00:00:00 2001 From: Christophe Dervieux Date: Thu, 5 Jun 2025 16:11:51 +0200 Subject: [PATCH 08/15] Don't use withr and pass env to the processx call directly --- DESCRIPTION | 4 ++-- R/quarto.R | 22 ++++++++++++++++++---- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index e25cc263..d560673c 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -30,7 +30,6 @@ Imports: rstudioapi, tools, utils, - withr, xfun, yaml (>= 2.3.10) Suggests: @@ -54,7 +53,8 @@ Suggests: thematic, tidyverse, tinytable, - whoami + whoami, + withr VignetteBuilder: quarto Config/testthat/edition: 3 diff --git a/R/quarto.R b/R/quarto.R index 085c084f..c1ca568e 100644 --- a/R/quarto.R +++ b/R/quarto.R @@ -133,18 +133,32 @@ quarto_run <- function( ..., .call = rlang::caller_env() ) { + # To store any environment variables to pass to the process + custom_env <- NULL + # This is required due to a bug in QUARTO CLI, fixed only in 1.8+ # https://github.com/quarto-dev/quarto-cli/pull/12887 - custom_env <- NULL if (!quarto_available(min = "1.8.13")) { - custom_env <- c("current", QUARTO_R = R.home("bin")) + custom_env <- c(custom_env, QUARTO_R = R.home("bin")) } + + # handle session .libpaths() for background session + # It needs to be passed if .libPaths() was modified in the current R session + # (e.g. to install dev package in a temporary library) opt_in_libpath <- getOption("quarto.use_libpaths", TRUE) if (isTRUE(opt_in_libpath) && !is.null(libpaths)) { - withr::local_envvar(list( + custom_env <- c( + custom_env, R_LIBS = paste(libpaths, collapse = .Platform$path.sep) - )) + ) } + + # This is required because `"current"` only is not supported by processx + # FIXME: https://github.com/r-lib/processx/issues/399 + if (!is.null(custom_env)) { + custom_env <- c("current", custom_env) + } + res <- withCallingHandlers( processx::run( quarto_bin, From 8ea8d966c7d2854e933529808f5acaf0253f96d5 Mon Sep 17 00:00:00 2001 From: Christophe Dervieux Date: Mon, 20 Oct 2025 15:38:43 +0200 Subject: [PATCH 09/15] Update snapshot --- tests/testthat/_snaps/spin/spin_preamble-custom-preamble.R | 2 +- tests/testthat/_snaps/spin/spin_preamble-custom-title.R | 2 +- tests/testthat/_snaps/spin/spin_preamble-empty.R | 3 ++- tests/testthat/_snaps/spin/spin_preamble-preamble-title.R | 2 +- tests/testthat/_snaps/spin/spin_preamble-title-override.R | 2 +- tests/testthat/_snaps/spin/spin_preamble.R | 2 +- tests/testthat/_snaps/utils-extract/purl.R | 4 +++- 7 files changed, 10 insertions(+), 7 deletions(-) diff --git a/tests/testthat/_snaps/spin/spin_preamble-custom-preamble.R b/tests/testthat/_snaps/spin/spin_preamble-custom-preamble.R index e2b5cf4b..57b52142 100644 --- a/tests/testthat/_snaps/spin/spin_preamble-custom-preamble.R +++ b/tests/testthat/_snaps/spin/spin_preamble-custom-preamble.R @@ -3,7 +3,7 @@ #' author: John Doe #' format: html #' --- -#' +#' library(ggplot2) plot(1:10) diff --git a/tests/testthat/_snaps/spin/spin_preamble-custom-title.R b/tests/testthat/_snaps/spin/spin_preamble-custom-title.R index f30743bd..26d6fcaf 100644 --- a/tests/testthat/_snaps/spin/spin_preamble-custom-title.R +++ b/tests/testthat/_snaps/spin/spin_preamble-custom-title.R @@ -1,7 +1,7 @@ #' --- #' title: Custom Analysis #' --- -#' +#' x <- 1 y <- 2 diff --git a/tests/testthat/_snaps/spin/spin_preamble-empty.R b/tests/testthat/_snaps/spin/spin_preamble-empty.R index 5aec2cdf..240b926b 100644 --- a/tests/testthat/_snaps/spin/spin_preamble-empty.R +++ b/tests/testthat/_snaps/spin/spin_preamble-empty.R @@ -1,5 +1,6 @@ #' --- #' title: report #' --- -#' +#' + diff --git a/tests/testthat/_snaps/spin/spin_preamble-preamble-title.R b/tests/testthat/_snaps/spin/spin_preamble-preamble-title.R index 15f39270..e3054fae 100644 --- a/tests/testthat/_snaps/spin/spin_preamble-preamble-title.R +++ b/tests/testthat/_snaps/spin/spin_preamble-preamble-title.R @@ -2,6 +2,6 @@ #' title: Preamble Title #' author: Jane Doe #' --- -#' +#' x <- 1 diff --git a/tests/testthat/_snaps/spin/spin_preamble-title-override.R b/tests/testthat/_snaps/spin/spin_preamble-title-override.R index 6058dbc2..81757d40 100644 --- a/tests/testthat/_snaps/spin/spin_preamble-title-override.R +++ b/tests/testthat/_snaps/spin/spin_preamble-title-override.R @@ -2,6 +2,6 @@ #' title: Override Title #' author: John Doe #' --- -#' +#' x <- 1 diff --git a/tests/testthat/_snaps/spin/spin_preamble.R b/tests/testthat/_snaps/spin/spin_preamble.R index 1b7568f4..c2c8b203 100644 --- a/tests/testthat/_snaps/spin/spin_preamble.R +++ b/tests/testthat/_snaps/spin/spin_preamble.R @@ -1,7 +1,7 @@ #' --- #' title: report #' --- -#' +#' x <- 1 y <- 2 diff --git a/tests/testthat/_snaps/utils-extract/purl.R b/tests/testthat/_snaps/utils-extract/purl.R index 48c0bff6..8bc32a62 100644 --- a/tests/testthat/_snaps/utils-extract/purl.R +++ b/tests/testthat/_snaps/utils-extract/purl.R @@ -2,7 +2,7 @@ #' title: Purl Test Document #' format: html #' --- -#' +#' #| label: my-label #| echo: false @@ -15,3 +15,5 @@ cat("more") #| eval: false # # This code should not run. # 1 + a + + From b4cafa1831bae327cfafe508f02caa51770ea438 Mon Sep 17 00:00:00 2001 From: Christophe Dervieux Date: Mon, 20 Oct 2025 17:08:01 +0200 Subject: [PATCH 10/15] devtools::document() --- DESCRIPTION | 2 +- man/check_newer_version.Rd | 2 +- man/find_project_root.Rd | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index d560673c..2c8ada48 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -60,6 +60,6 @@ VignetteBuilder: Config/testthat/edition: 3 Encoding: UTF-8 Roxygen: list(markdown = TRUE) -RoxygenNote: 7.3.2 +RoxygenNote: 7.3.3 SystemRequirements: Quarto command line tool (). diff --git a/man/check_newer_version.Rd b/man/check_newer_version.Rd index de69a225..42ea436e 100644 --- a/man/check_newer_version.Rd +++ b/man/check_newer_version.Rd @@ -47,7 +47,7 @@ information from quarto.org. If the network request fails, an error will be thro } \examples{ -\dontshow{if (quarto::quarto_available() && quarto:::has_internet("https://www.quarto.org")) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (quarto::quarto_available() && quarto:::has_internet("https://www.quarto.org")) withAutoprint(\{ # examplesIf} # Check current Quarto version check_newer_version() diff --git a/man/find_project_root.Rd b/man/find_project_root.Rd index d5df6e1c..a7e9576f 100644 --- a/man/find_project_root.Rd +++ b/man/find_project_root.Rd @@ -20,7 +20,7 @@ Unlike \code{\link[=get_running_project_root]{get_running_project_root()}}, this interactive sessions. } \examples{ -\dontshow{if (quarto_available()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (quarto_available()) withAutoprint(\{ # examplesIf} tmpdir <- tempfile() dir.create(tmpdir) find_project_root(tmpdir) From bfe37324572505780099b872ed1966625a27af08 Mon Sep 17 00:00:00 2001 From: Christophe Dervieux Date: Mon, 20 Oct 2025 17:09:18 +0200 Subject: [PATCH 11/15] Env var has changed name --- .github/workflows/R-CMD-check.yaml | 2 +- tests/testthat/test-quarto-args.R | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 253faa18..a1c7e343 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -75,7 +75,7 @@ jobs: - uses: r-lib/actions/check-r-package@v2 env: - QUARTO_R_QUIET: FALSE + R_QUARTO_QUIET: FALSE with: upload-snapshots: true args: ${{ format('c("--no-manual", "--as-cran"{0})', format('{0}', matrix.config.quarto) == 'false' && ',"--ignore-vignettes"' || '') }} diff --git a/tests/testthat/test-quarto-args.R b/tests/testthat/test-quarto-args.R index 071f8bb8..bc1f3d6b 100644 --- a/tests/testthat/test-quarto-args.R +++ b/tests/testthat/test-quarto-args.R @@ -24,7 +24,7 @@ test_that("create quiete arg", { }) test_that("quarto.quiet options takes over", { - withr::local_envvar(list(QUARTO_R_QUIET = NA)) + withr::local_envvar(list(R_QUARTO_QUIET = NA)) expect_identical(is_quiet(TRUE), TRUE) expect_identical(is_quiet(FALSE), FALSE) expect_identical(is_quiet(NA), FALSE) From 4680e0fd7feb8544ddee82cb70ac707d4fa18172 Mon Sep 17 00:00:00 2001 From: Christophe Dervieux Date: Mon, 20 Oct 2025 17:12:19 +0200 Subject: [PATCH 12/15] Remove duplicate test from rebase --- tests/testthat/test-quarto.R | 29 +++-------------------------- 1 file changed, 3 insertions(+), 26 deletions(-) diff --git a/tests/testthat/test-quarto.R b/tests/testthat/test-quarto.R index d248b2fa..d39e8296 100644 --- a/tests/testthat/test-quarto.R +++ b/tests/testthat/test-quarto.R @@ -124,28 +124,6 @@ test_that("quarto.quiet options controls echo and overwrite function argument", }) }) -test_that("quarto sees same libpaths as main process", { - skip_if_no_quarto() - skip_on_cran() - qmd <- local_qmd_file(c("```{r}", "#| echo: false", ".libPaths()", "```")) - tmp_lib <- withr::local_tempdir("tmp_libpath") - withr::local_libpaths(tmp_lib, action = "prefix") - withr::local_dir(dirname(qmd)) - out <- "out.md" - # .libPaths() is known in Quarto render - out <- .render_and_read(qmd, output_format = "gfm") - expect_match(out, basename(tmp_lib), all = FALSE, fixed = TRUE) - # Opting-out globally - withr::with_options( - list(quarto.use_libpaths = FALSE), - out <- .render_and_read(qmd, output_format = "gfm") - ) - expect_no_match(out, basename(tmp_lib), fixed = TRUE) - # Opting-out at command - out <- .render_and_read(qmd, output_format = "gfm", libpaths = NULL) - expect_no_match(out, basename(tmp_lib), fixed = TRUE) -}) - test_that("quarto_available()", { expect_error( quarto_available("1.5", "1.4"), @@ -184,7 +162,7 @@ test_that("quarto sees same libpaths as main process", { skip_if_no_quarto() skip_on_cran() qmd <- local_qmd_file(c("```{r}", "#| echo: false", ".libPaths()", "```")) - tmp_lib <- withr::local_tempdir("tmp_libpath") + tmp_lib <- withr::local_tempdir("tmp_libpath") withr::local_libpaths(tmp_lib, action = "prefix") withr::local_dir(dirname(qmd)) out <- "out.md" @@ -193,12 +171,11 @@ test_that("quarto sees same libpaths as main process", { expect_match(out, basename(tmp_lib), all = FALSE, fixed = TRUE) # Opting-out globally withr::with_options( - list(quarto.use_libpaths = FALSE), + list(quarto.use_libpaths = FALSE), out <- .render_and_read(qmd, output_format = "gfm") ) expect_no_match(out, basename(tmp_lib), fixed = TRUE) # Opting-out at command out <- .render_and_read(qmd, output_format = "gfm", libpaths = NULL) expect_no_match(out, basename(tmp_lib), fixed = TRUE) - -}) \ No newline at end of file +}) From 1b611d1ff2d4c4502c9eda9b552d6f88e6db7794 Mon Sep 17 00:00:00 2001 From: Christophe Dervieux Date: Mon, 20 Oct 2025 17:12:56 +0200 Subject: [PATCH 13/15] typo in NEWS --- NEWS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index fa03ec7d..b6afd5bc 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,6 @@ # quarto (development version) -- `.libPaths()` from the calling R session will now be passed by default to all call to quarto as a subprocess. This should solve issue with **pkgdown** or when building vignettes (thanks, ) +- `.libPaths()` from the calling R session will now be passed by default to all call to quarto as a subprocess. This should solve issue with **pkgdown** or when building vignettes. # quarto 1.5.1 From a9c59e44b714941cd121fd335f4cf09183611f3e Mon Sep 17 00:00:00 2001 From: Christophe Dervieux Date: Mon, 20 Oct 2025 17:26:56 +0200 Subject: [PATCH 14/15] Don't run with R_QUARTO_QUIET false as this messes up snapshot test --- .github/workflows/R-CMD-check.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index a1c7e343..ac77d202 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -74,8 +74,6 @@ jobs: install-pandoc: false - uses: r-lib/actions/check-r-package@v2 - env: - R_QUARTO_QUIET: FALSE with: upload-snapshots: true args: ${{ format('c("--no-manual", "--as-cran"{0})', format('{0}', matrix.config.quarto) == 'false' && ',"--ignore-vignettes"' || '') }} From 0193b90505a2fc99250de214e03f62e20ed05a4c Mon Sep 17 00:00:00 2001 From: Christophe Dervieux Date: Mon, 20 Oct 2025 17:42:07 +0200 Subject: [PATCH 15/15] skip non-working test on Windows https://github.com/quarto-dev/quarto-r/issues/217 is the issue. Somehow setting R_LIBS in the process that calls R CMD check does not work on windows like it does on Linux and Mac. We'll opt-in back the test on windows when #217 is solved --- tests/testthat/test-quarto.R | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/testthat/test-quarto.R b/tests/testthat/test-quarto.R index d39e8296..9111563f 100644 --- a/tests/testthat/test-quarto.R +++ b/tests/testthat/test-quarto.R @@ -161,6 +161,9 @@ test_that("quarto_available()", { test_that("quarto sees same libpaths as main process", { skip_if_no_quarto() skip_on_cran() + # Issue on windows with libpaths + # https://github.com/quarto-dev/quarto-r/issues/217 + skip_on_os("windows") qmd <- local_qmd_file(c("```{r}", "#| echo: false", ".libPaths()", "```")) tmp_lib <- withr::local_tempdir("tmp_libpath") withr::local_libpaths(tmp_lib, action = "prefix")