quarto-dev / quarto-dev/quarto-cli
Can `knitr::opts_knit$get("quarto.version")` return the specific Quarto version?
@cderv is already working on this.
Since Sep 25, 2025.
- Dominant language
- JavaScript
- Stars
- 6k
- Forks
- 458
- Avg merge
- 1d 9h
- Merged PRs (30d)
- 41
Description
Quarto sets the knitr option quarto.version = 1
This is then generally used as a signal that knitr is executing in a Quarto context with a check like
!is.null(knitr::opts_knit$get("quarto.version"))
or in some packages, like flextable there are more complicated checks that insinuate that quarto.version might change over time
is_in_quarto <- function() {
if (getRversion() >= numeric_version("4.4.0")) {
isTRUE(knitr::opts_knit$get("quarto.version") > 0)
} else {
isTRUE(knitr::opts_knit$get("quarto.version") > numeric_version("0"))
}
}
I think it'd be helpful to have this version match the Quarto binary version. I can't find another way to find out, from R, what exact version of quarto is in use.
In v1.9 I think the following will be possible, but the quarto.version knitr option is definitely easier to access.
jsonlite::read_json(Sys.getenv("QUARTO_EXECUTE_INFO"))[["format"]][["metadata"]][["quarto-version"]]
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.