Problem rendering Quarto when using renv and specific packages

I can't seem to render a Quarto HTML document when calling functions from specific packages (so far I've identified the problem when using kableExtra as well as when using ggiraph) in a project that is using renv.

Here are the steps to reproduce. This example uses kableExtra but similar errors occur when using ggiraph:

(1) Using the RStudio graphical interface, create a new project, clicking the option to use renv (I'm using renv 0.15.5).
(2) Using the RStudio graphical interface, create a new Quarto file. Follow the prompt to install the rmarkdown package.
(3) Install kableExtra using the console: install.packages('kableExtra')
(4) Write a Quarto document:

---
title: "Untitled"
format: html
editor: visual
---

## Title

```{r}
mtcars |> 
  kableExtra::kbl()
```

(5) (At this point, the code chunk runs perfectly and generates the expected output when I run it interactively).
(6) Save script as test.qmd in the root of the project directory
(7) Press Render. Error message:

Error in normalizePath(path.expand(path), winslash, mustWork) : 
  path[1]="test_files\libs/kePrint-0.0.1": The system cannot find the path specified
Calls: .main ... html_dependencies_as_string -> lapply -> FUN -> normalizePath
In addition: Warning messages:
1: In dir.create(outputDir) :
  cannot create dir 'test_files\libs', reason 'No such file or directory'
2: In dir.create(target_dir) :
  cannot create dir 'test_files\libs\kePrint-0.0.1', reason 'No such file or directory'
Execution halted

(8) The project renders as expected if I deactivate renv using renv::deactivate() and then press Render.

Operating system: Windows 10
RStudio verison: ‘2022.7.0.548’, "Spotted Wakerobin"
R platform: x86_64-w64-mingw32
R version: 4.2.1 (2022-06-23 ucrt), Funny-Looking Kid

I can reproduce this. This seems to be an issue either with Quarto, or with some R packages. I'll look into that

It seems a folder is not correctly created in the process. I don't think this has to do with renv It seems I can reproduce it without it.

Can you compare package version within your renv and within your R global environment (without renv)? this could give us hint.

Current workaround is to manaully do

dir.create("test_files")

where test is because your file is named test.qmd

So this is coming from new htmltools version 0.5.3. There was a change in copyDependencyToDir which creates this issue.

Please to install 0.5.2 as a workaround for this.

renv::install("htmltools@0.5.2")

or

remotes::install_version("htmltools", "0.5.2")
3 Likes

Thank you so much for the very quick and useful reply! Installing the older version of htmltools solved the problem.

This is an issue which will be probably solved . For reference: Quarto with R does not correctly use htmltools for dependency creation · Issue #1497 · quarto-dev/quarto-cli · GitHub

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.