Problems with instllation of packages: installation of package ‘XXX’ had non-zero exit status. Rtools is required to build R packages but is not currently installed.

I cannot install nearly no package and Rtool is installed (I could install the car Package and R has no problems with instlling packages, only RStudio. I deinstalled R, RStudio andRtools and installed it again, this did not help. I did not have the problems some months ago.
I would be very gölad about help!

RStudio-2022.02.0-443.exe, Windows 10

install.packages("knitr")
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/
also installing the dependency ‘xfun’

There are binary versions available but the source versions are later:
binary source needs_compilation
xfun 0.13 0.30 TRUE
knitr 1.28 1.37 FALSE

rying URL
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

installing the source package ‘knitr’

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


Fuer Lehrzwecke zusammengestellt vom
Institut fuer Angewandte Statistik und EDV, BOKU Wien
Anleitungen finden Sie unter:


Das aktuelle Arbeitsverzeichnis ist:
C:/Users/irauscher/Documents

Zum Starten des R Commanders tippen Sie bitte:
library("Rcmdr")
bzw.
library("RcmdrPlugin.iasc")

  • installing source package 'knitr' ...
    ** Paket 'knitr' erfolgreich entpackt und MD5 Summen überprüft
    ** 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.27 is required
    ERROR: lazy loading failed for package 'knitr'
  • removing 'C:/Users/irauscher/Documents/R-portabel/library/knitr'
    In R CMD INSTALL
    Warning in install.packages :
    installation of package ‘knitr’ had non-zero exit status

The downloaded source packages are in

What are your R and RTools versions? Maybe you have not installed a suitable version of RTools for your R version or you haven't configured it correctly.

Rtools 4.0.3.0 no special configuration
R 4.0.4

You have to add RTools to your PATH environment variable as specified on the installation instructions. Have you done that?

No installation instruction gives me a suggestion where to install thats all, all other is new to me. Can i add the path manually in r?

Yes, just follow the instructions

https://cran.r-project.org/bin/windows/Rtools/

Putting Rtools on the PATH

After installation is complete, you need to perform one more step to be able to compile R packages: we put the location of the Rtools make utilities ( bash , make , etc) on the PATH . The easiest way to do so is by creating a text file .Renviron in your Documents folder which contains the following line:

PATH="${RTOOLS40_HOME}\usr\bin;${PATH}"

You can do this with a text editor, or from R like so (note that in R code you need to escape backslashes):

write('PATH="${RTOOLS40_HOME}\\usr\\bin;${PATH}"', file = "~/.Renviron", append = TRUE)

Restart R, and verify that make can be found, which should show the path to your Rtools installation.

Sys.which("make")
## "C:\\rtools40\\usr\\bin\\make.exe"

Thnk you very much!
I added the path in R, after that make was found, but still afer starting the computer WARNING: Rtools is required to build R packages but is not currently installed. Please download and install the appropriate version of Rtools before proceeding:
after trying to instll.packege("knitr") or other

perhaps I did not understand the sys.which: it showed only "make" not the path

Maybe you are overwriting the location with another .Renviron file, it is hard to tell without having access to your system. The installation instructions should work out of the box, they do for most people so I suspect this is a a misconfiguration specific to your system.

is there a suggestion what to do?

library(pkgbuild)

has_rtools()
[1] TRUE
check_rtools(debug = FALSE)
[1] TRUE
rtools_path()
[1] "C:\rtools40/usr/bin" "C:\rtools40/ucrt64/bin"

Only RStudio is not finding it

1 Like

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.