Problems installing RMarkdown for R v2023.06.1 on a Mac

I'm having troubles installing RMarkdown for using knitr and publish my work, I'm using R Studio v2023.06.1 on a Mac with a macOS Monterey version 12.6.3. This is what I'm getting:

install.packages("knitr")
also installing the dependency ‘xfun’

There are binary versions available but the source versions are later:
binary source needs_compilation
xfun 0.30 0.40 TRUE
knitr 1.38 1.44 FALSE

Do you want to install from sources the package which needs compilation? (Yes/no/cancel) no
trying URL 'https://cran.rstudio.com/bin/macosx/contrib/4.0/xfun_0.30.tgz'
Content type 'application/x-gzip' length 392013 bytes (382 KB)

downloaded 382 KB

The downloaded binary packages are in
/var/folders/9s/pn6v4gc16kj08cl5t9t_m03w0000gn/T//RtmprSEJ0v/downloaded_packages
installing the source package ‘knitr’

trying URL 'https://cran.rstudio.com/src/contrib/knitr_1.44.tar.gz'
Content type 'application/x-gzip' length 898526 bytes (877 KB)

downloaded 877 KB

  • installing source package ‘knitr’ ...
    ** package ‘knitr’ successfully unpacked and MD5 sums checked
    ** using staged installation
    ** R
    ** demo
    ** inst
    ** byte-compile and prepare package for lazy loading
    Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) :
    namespace ‘xfun’ 0.30 is being loaded, but >= 0.39 is required
    Calls: ... namespaceImportFrom -> asNamespace -> loadNamespace
    Execution halted
    ERROR: lazy loading failed for package ‘knitr’
  • removing ‘/Library/Frameworks/R.framework/Versions/4.0/Resources/library/knitr’
    Warning in install.packages :
    installation of package ‘knitr’ had non-zero exit status

The downloaded source packages are in
‘/private/var/folders/9s/pn6v4gc16kj08cl5t9t_m03w0000gn/T/RtmprSEJ0v/downloaded_packages’

Any idea?

Thanks in advanced

can be addressed by

install.packages("xfun")

technocrat, thanks for your input, I tried in different ways, by compilation, binary and different version of fun loaded in CRAN: r-release (arm64), r-oldrel (arm64), r-release (x86_64), r-oldrel (x86_64). Nothing works. Is it the problem with R Studio version?

It won't be an RStudio problem if you can do it with the separate R.app or by invoking R from a terminal (just be a bit patient because it can take a while for the choose repo location box to come up.)

This is not an RStudio problem. You are using R 4.0.x, and CRAN does not have the latest binary packages for this R version.

If you use CRAN, then you'll need to install packages from source to get the latest versions. Try installing the Xcode command line tools and then running

install.packages("xfun", type = "source")

If this fails, then show us the full output.

Another solution is to update your R version, if you can do that. If you do this then you don't need the command line tools now, but you'll probably need them at some point in the future, so you might as well install them.

1 Like

Thanks everyone for your replies, I just solved the problem by installing the latest version of R Studio 2023.09.0.

For the record, it is very unlikely that this was a problem with RStudio, and I suspect that you also installed the latest version of R, which actually solved the issue. Probably.

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