How quarto looks for R installation?


I am wondering how quarto looks for an R installation in Windows.

I am getting an "Unable to locate an installed version of R." error, even though R, Rterm and Rscript are all in the system path.

quarto check also shows

[>] Checking R installation...........(None)

      Unable to locate an installed version of R.
      Install R from

It's actually kind of weird, because if I run

quarto preview doc.qmd --no-browser --no-watch-inputs

It successfully renders the document into the first output format in it (revealjs). But if I try to render it into docx, it fails.

quarto preview doc.qmd --no-browser --no-watch-inputs --to docx

So I am wondering how quarto looks for an R installation.
Does quarto always look for R in the Program Files folder?
I ask because I use scoop to install R, so quarto cannot find R in the Program Files. But R is indeed in the path. I also use scoop to install python, and in that case, quarto has no problems finding it.

So I am puzzled. Any ideas/explanaition would be most appreciated. Thx.

I am not qualified to say anything about quarto source code (so take my answer with a grain of salt), but I was curious of the same thing myself. I had been using quarto check to screen for dependencies in an application I am working on.

Lucky for us, quarto is open source. As far as I can tell (and looking at v 1.3.321 in github), it tries a variety of things to get the path to "Rscript".

Skimming the source code in the link, here's what I can tell...

  1. Using Deno, try to get QUARTO_R environment variable.
  2. Using Deno, try to get R_HOME environment variable.
  3. Try to get the path to Rscript using which in linux and where in windows
  4. In windows, try to look it up in the registry
  5. In windows, try to search for the install in "Program Files"

AFAIK, there isn't a predetermined/reliable way to find if R is actually installed-- the registry setting is optional when installing R, and environment variables might not be reliable. So this shotgun approach is the way to go, right? Anyone have other ideas?

Thinking about this some more, quarto is often (mostly?) used in the context of "a project" in some programming language. The project could be an Rproj or a Python package, or whatever project structure is used by the other code-block languages that Quarto supports. In R and Python, at least, there exists some tooling for defining a virtual environment (renv in R and virtualenv's in python). It would be cool if quarto could look for or be told explicitly which environment it's actually supposed to work in. I hope that's on the radar.

We are supposed to be working with project having set up a virtual environmen See Quarto – Virtual Environments

yes we are trying to find a R installation as we can - if we can't the way to go is to set the QUARTO_R environment variables.

Or use quarto in a IDE that is already setup with R (like RStudio IDE or VSCODE)

1 Like

This topic was automatically closed 42 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.