quarto: unable to locate R installation

I am using Mac OS Monterey Version 12.4. When attempting to render Quarto, I see the following error:

Error in assignInNamespace("htmlPreserve", htmlPreserve, ns = "htmltools") : 
  could not find function "assignInNamespace"
Calls: .main -> source -> withVisible -> eval -> eval
Execution halted
Error in packageVersion("rmarkdown") : 
  could not find function "packageVersion"
Calls: cat -> paste0
Execution halted

Unable to locate an installed version of R.
Install R from https://cloud.r-project.org/

What I have done so far to try to address this issue:

  1. Downloaded the latest versions of R (4.2.1), R Studio (2022/07, 1-554), and Quarto (1.0.38), and the rmarkdown package (2.14) [FYI, I just checked rmarkdown's package version with packageVersion - which the error claims is not loaded]
  2. Tried to manually set the PATH to the R library(s): Adding to the PATH variable
old_path <- Sys.getenv("PATH")

Sys.setenv(PATH = paste(old_path, "/Library/Frameworks/R.framework/Resources/library", sep = ":"))

I suspect the issue is because I am working in a project located on a Box (i.e. in the cloud) directory. I am able to use R just fine in R Studio, so it must be a Quarto specific issue with accessing R when working in a cloud environment(?).

Any assistance is greatly appreciated!

Are you working inside or outside RStudio IDE ?

Can you share the result of quarto check please ?
This should tell us what Quarto is seeing - like finding R installation or not.

Thank you !

My apologies! Inside R Studio IDE.

Here is quarto check


Elizabeths-MacBook-Pro:r elizabethdavis$ quarto check

[✓] Checking Quarto installation......OK
      Version: 1.0.38
      Path: /Applications/quarto/bin

[✓] Checking basic markdown render....OK

[✓] Checking Python 3 installation....OK
      Version: 3.8.9
      Path: /Library/Developer/CommandLineTools/usr/bin/python3
      Jupyter: (None)

      Jupyter is not available in this Python installation.
      Install with python3 -m pip install jupyter

(|) Checking R installation...........Error in packageVersion("rmarkdown") : 
  could not find function "packageVersion"
Calls: cat -> paste0
Execution halted
[✓] Checking R installation...........(None)

      Unable to locate an installed version of R.
      Install R from https://cloud.r-project.org/

Can you try our latest version ?

Just to see if the problem is fixed there ?

Thank you.

also this message can happen when R does not load the default packages by default, among which utils.

Usually this happens if you have options(defaultPackages = character()) or R_DEFAULT_PACKAGES=NULL set somewhere in your environment.

Example with Powershell

> $env:R_DEFAULT_PACKAGES=$null
> Rscript --vanilla -e "packageVersion('rmarkdown')"
[1] '2.16.1'

> $env:R_DEFAULT_PACKAGES="NULL"
> Rscript --vanilla -e "packageVersion('rmarkdown')"
Erreur dans packageVersion("rmarkdown") :
  impossible de trouver la fonction "packageVersion"
Exécution arrêtée

We'll improve that on our side, but still a specific use case.

Do you have one of those configuration set by any chance ?

I have added an issue for this anyway: Correctly namespace usage of R default package functions like utils · Issue #2187 · quarto-dev/quarto-cli · GitHub

Thank you very much Christophe. I have downloaded the latest Quarto version, but I am still encountering the same issue. I don't believe I have either of the options you suggested set;

From the digging I have done, it looks like one possibility is that the error is to do with my PATH. However, when I have tried to manually set the PATH, it has not fixed the problem.

Thank you for looking into this!

Hi,

I edited your post to hide the env var. Lost of personal info from your system not needed.

I saw /Users/elizabethdavis/Applications/quarto/binso it seems that Quarto is indeed in your path.

but I am still encountering the same issue.

The issue with packageVersion not found ?

This is thrown by Quarto, so it means it is found in PATH. But somehow, utils package is not used in your R installation.

Can you check that it work on your R installation :

utils::packageVersion("rmarkdown")

Hi,
Thank you! The output of utils::packageVersion("rmarkdown") is '2.14'.

And yes, same errors as before when I attempt to render the hello.qmd doc:

Error in assignInNamespace("htmlPreserve", htmlPreserve, ns = "htmltools") : 
  could not find function "assignInNamespace"
Calls: .main -> source -> withVisible -> eval -> eval
Execution halted
Error in packageVersion("rmarkdown") : 
  could not find function "packageVersion"
Calls: cat -> paste0
Execution halted

Unable to locate an installed version of R.
Install R from https://cloud.r-project.org/

I have redownloaded R a few times now to try to address this issue, and have not changed the download path. I wonder if it is something to do with administrative privileges on my machine, although as far as I know I have sole control over it- there are no other user accounts.

Thank you very much again for all of your assistance with this.

This should be fixed in future version of Quarto

However, you should be able to make it work by checking what I shared before

R utils package should be installed and loaded in R by default. I don't know what is the issue.

Thank you Christophe. I tried what you suggested, but it seemed like Quarto was still unable to locate my installation of R. I am really not sure how to fix the problem, but have "solved" it by rendering the documents using R Studio Cloud. I will test the IDE again after the next release of Quarto, to see if your fix has solved the problem.

Thank you for all of your assistance with this!

Ok great.

You could already try the pre-release of Quarto to see if this is fixed:

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