installation of package ‘PACKAGE ATTEMPTING TO INSTALL’ had non-zero exit status

I am attempting to use Rstudio on my work computer. I was unable to create an rmarkdown. I was getting errors that i needed to download certain packages. I download the packages and get the error above.
I downloaded Rstudio version ""Ghost Orchid" Release (fc9e2179, 2022-01-04) for Windows" and rtools 3.5. I have tried to download several packages and I keep getting the same error "installation of package ‘PACKAGE ATTEMPTING TO INSTALL’ had non-zero exit status." I checked my Paths using .libPaths() and got:
[1] "C:/Users/Usernumber/OneDrive -company/My Documents/R/win-library/3.6"
[2] "C:/Program Files/R/R-3.6.3/library"

I try installing 'rmarkdown' and get:

install.packages('rmarkdown')
Installing package into ‘C:/Users/userumber/OneDrive - company/My Documents/R/win-library/3.6’
(as ‘lib’ is unspecified)
also installing the dependencies ‘xfun’, ‘knitr’, ‘tinytex’

There are binary versions available but the source versions are later:
binary source needs_compilation
xfun 0.22 0.29 TRUE
knitr 1.33 1.37 FALSE
tinytex 0.31 0.36 FALSE
rmarkdown 2.8 2.11 FALSE

trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.6/xfun_0.22.zip'
Content type 'application/zip' length 323923 bytes (316 KB)
downloaded 316 KB

package ‘xfun’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in
C:\Users\usernumber\AppData\Local\Temp\RtmpqQI1ZK\downloaded_packages
installing the source packages ‘knitr’, ‘tinytex’, ‘rmarkdown’

trying URL
Content type 'application/x-gzip' length 895567 bytes (874 KB)
downloaded 874 KB

trying URL
Content type 'application/x-gzip' length 31525 bytes (30 KB)
downloaded 30 KB

trying URL
Content type 'application/x-gzip' length 3212367 bytes (3.1 MB)
downloaded 3.1 MB

  • 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.22 is being loaded, but >= 0.27 is required
    Calls: ... namespaceImportFrom -> asNamespace -> loadNamespace
    Execution halted
    ERROR: lazy loading failed for package 'knitr'
  • removing 'C:/Users/username/OneDrive - company/My Documents/R/win-library/3.6/knitr'
    Warning in install.packages :
    installation of package ‘knitr’ had non-zero exit status
  • installing source package 'tinytex' ...
    ** package 'tinytex' successfully unpacked and MD5 sums checked
    ** using staged installation
    ** R
    ** 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.22 is being loaded, but >= 0.29 is required
    Calls: ... namespaceImportFrom -> asNamespace -> loadNamespace
    Execution halted
    ERROR: lazy loading failed for package 'tinytex'
  • removing 'C:/Users/username/OneDrive - company/My Documents/R/win-library/3.6/tinytex'
    Warning in install.packages :
    installation of package ‘tinytex’ had non-zero exit status
    ERROR: dependencies 'knitr', 'tinytex' are not available for package 'rmarkdown'
  • removing 'C:/Users/username/OneDrive - company/My Documents/R/win-library/3.6/rmarkdown'
    Warning in install.packages :
    installation of package ‘rmarkdown’ had non-zero exit status

The downloaded source packages are in
‘C:\Users\username\AppData\Local\Temp\RtmpqQI1ZK\downloaded_packages’

Please help so that I can start utilizing Rstudio.

Thanks!

This is asking you to update the xfun package but you need to choose to install from "source" when asked since there are no newer binary versions of the package four your R version (which is quite old).

Also, be aware that R has known issues with package libraries set in cloud-synced folders (OneDrive in your case), I would strongly recommend setting your package library in a non-synced folder.

You can change the default library folder by setting your R_LIBS_SITE environmental variable in a .Reviron or .Rprofile file. For example:

# In a .Renviron file you can set it by adding a line like this one with the desired location 
R_LIBS_SITE="C:\\Program Files\\R\\R-4.1.2\\library"

For a more detailed explanation, you can read this blog post

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