Latest RStudio unable to install or run rmarkdown packages

I first noticed a problem when every time I saved a Rmarkdown package it was saved as a raw notes file, I found I could not save markdown packages at all. After updating R to the latest version using the download RStudio-1.4.1106 I found I could not even open a new markdown file.

I get the error that I need to install the latest versions of knitr, markdown, xfun and tinytex. I have tried to install them. I have installed them using the automatic download system, by typing in install.packages or by going through the tools->install packages function.

I get the error:

> install.packages("rmarkdown")
WARNING: Rtools is required to build R packages but is not currently installed. Please download and install the appropriate version of Rtools before proceeding:

https://cran.rstudio.com/bin/windows/Rtools/
Installing package into ‘C:/Users/Ella Bruce/Documents/R/win-library/3.5’
(as ‘lib’ is unspecified)
also installing the dependencies ‘knitr’, ‘tinytex’, ‘xfun’


  There are binary versions available but the source versions are later:
          binary source needs_compilation
knitr       1.28   1.31             FALSE
tinytex     0.22   0.30             FALSE
xfun        0.13   0.21              TRUE
rmarkdown    2.1    2.7             FALSE

  Binaries will be installed
trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.5/xfun_0.13.zip'
Content type 'application/zip' length 184719 bytes (180 KB)
downloaded 180 KB

package ‘xfun’ successfully unpacked and MD5 sums checked

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

trying URL 'https://cran.rstudio.com/src/contrib/knitr_1.31.tar.gz'
Content type 'application/x-gzip' length 891732 bytes (870 KB)
downloaded 870 KB

trying URL 'https://cran.rstudio.com/src/contrib/tinytex_0.30.tar.gz'
Content type 'application/x-gzip' length 28839 bytes (28 KB)
downloaded 28 KB

trying URL 'https://cran.rstudio.com/src/contrib/rmarkdown_2.7.tar.gz'
Content type 'application/x-gzip' length 3215356 bytes (3.1 MB)
downloaded 3.1 MB

* installing *source* package 'knitr' ...
** package 'knitr' successfully unpacked and MD5 sums checked
** 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.13 is being loaded, but >= 0.19 is required
ERROR: lazy loading failed for package 'knitr'
* removing 'C:/Users/Ella Bruce/Documents/R/win-library/3.5/knitr'
In R CMD INSTALL
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
** 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.13 is being loaded, but >= 0.19 is required
ERROR: lazy loading failed for package 'tinytex'
* removing 'C:/Users/Ella Bruce/Documents/R/win-library/3.5/tinytex'
In R CMD INSTALL
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/Ella Bruce/Documents/R/win-library/3.5/rmarkdown'
In R CMD INSTALL
Warning in install.packages :
  installation of package ‘rmarkdown’ had non-zero exit status

The downloaded source packages are in
	‘C:\Users\Ella Bruce\AppData\Local\Temp\RtmpIDt8HA\downloaded_packages’

This only seems to happen for packages related to Rmarkdown as I have managed to reinstall other packages and successfully installed new packages.
I would really appreciate some help in working out what is going wrong here.

Hi @EBruce,
Welcome to the RStudio Community Forum.

If you have upgraded to the latest version of R (4.0.4) then your user package library should be in
C:/Users/xxxx xxxx/Documents/R/win-library/4.0/
but the output is suggesting that it's in
C:/Users/xxxx xxxxx/Documents/R/win-library/3.5/
When you upgrade to a new major version of R you need to reinstall all your existing packages to the new library.

Try the simple route of running RStudio (check the startup message to see that its running R-4.0.4).
Run .libPaths() to check that the path to your packages is correct for the new version.
Click "Install" in the Packages tab and type the name of the package you need. RStudio should put the package in the newest version of the library.
I suggest you stick to packages in "binary" form first (no compilation required). If you want to install from "source" you'll need to install Rtools which can be downloaded from CRAN. See e.g. here for instructions:

1 Like

Thank you very much for your help, it will take a while to reinstall every package but at least I have my libraries and paths sorted out now.

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.