quarto-dev / quarto-dev/quarto-cli

Can `knitr::opts_knit$get("quarto.version")` return the specific Quarto version?

Open
#13,420 0 comments 1 reaction 1 assignee View on GitHub

@cderv is already working on this.

Since Sep 25, 2025.

engines-knitr enhancement
Dominant language
JavaScript
Stars
6k
Forks
458
Avg merge
1d 9h
Merged PRs (30d)
41

Description

Quarto sets the knitr option quarto.version = 1

https://github.com/quarto-dev/quarto-cli/blob/304399335b840dfa5b4e84a2875d25ebd7ed0322/src/resources/rmd/execute.R#L300

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.