Skip to content

Path issue in Quarto vignette / article #2722

@olivroy

Description

@olivroy

I get an issue while trying to read external content in the vignettes folder with a Quarto article when building pkgdown.

Let's say my vignettes/ folder contains the following files

vignettes/article-quarto.qmd

---
title: "Title"
---

```{r}
#| label: setup
knitr::read_chunk("visual_test.R")
```

```{r}
#| label: simple
```

vignette/article.Rmd

---
title: "Case Study: gtcars"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{Case Study: gtcars}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

```{r options, message=FALSE, warning=FALSE, include=FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

library(gt)
library(dplyr)
library(tibble)
knitr::read_chunk("visual_tests.R")
```

```{r}
#| label: simple
```

vignettes/visual_tests.R

# I would like to have those reused inside my articles / vignettes
## ----simple, echo=TRUE-------------------------------
1 + 1

I get an issue that Quarto can't find the path.

Running pkgdown::build_article("article-quarto", quiet = FALSE) errors, while it works with the Rmd article.

Error in `file()`:
! cannot open the connection
Backtrace:
  1. knitr::knit(..., tangle = TRUE)
  2. knitr:::process_file(text, output)
  5. knitr:::process_tangle(group)
  6. knitr:::tangle_block(x)
  9. knitr::read_chunk("knitr-chunks.R")
 10. xfun::read_utf8(path)
 11. base::readLines(con, encoding = "UTF-8", warn = FALSE)
 12. base::file(con, "r")
Warning message:
In file(con, "r") :
  cannot open file 'knitr-chunks.R': No such file or directory
Calls: build_articles ... eval -> read_chunk -> read_utf8 -> readLines -> file

Quitting from lines 18-19 [unnamed-chunk-2] (/var/folders/m5/623cy_fn5ts603hrw87n4_p40000gn/T//RtmpRNRUJv/file37963f0180c0.md)

I have confirmed that this is not an issue for a Rmd vignette. I am simply looking for a way to reuse things in a Quarto vignette.

Happy to provide a reprex with a self-contained directory if this isn't possible to reproduce easily

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions