0

After updating to R 4.0.0 on my Windows machine, I can't install some packages such as xml2 (the same goes for foreign and nnet). When I try to install I get this error message:

* installing *source* package 'foreign' ...
** package 'foreign' successfully unpacked and MD5 sums checked
** using staged installation
** libs

*** arch - i386
"c:/rtools40/mingw32/bin/"gcc  -I"C:/PROGRA~1/R/R-40~1.0/include" -DNDEBUG          -O2 -Wall  -std=gnu99 -mfpmath=sse -msse2 -mstackrealign -c R_systat.c -o R_systat.o
sh: c:/rtools40/mingw32/bin/gcc: No such file or directory
make: *** [C:/PROGRA~1/R/R-40~1.0/etc/i386/Makeconf:222: R_systat.o] Error 127
ERROR: compilation failed for package 'foreign'
* removing 'C:/R-PKGS/win-library/3.6/foreign'
* restoring previous 'C:/R-PKGS/win-library/3.6/foreign'
Warning in install.packages :
  installation of package ‘foreign’ had non-zero exit status

The main reason for installing the xml2 package is that I want to use the tidyverse package, but when I try to run library(tidyverse) I get this message:

Error: package or namespace load failed for ‘tidyverse’:
 package ‘xml2’ was installed before R 4.0.0: please re-install it

So I guess that I will have to be able to solve the problem that occurs when I try to install the xml2 package as it may occur in the future when other packages will have to be updated.

Kind regards, Andrés

  • 1
    Are you entirely sure rtools40 installed correctly? – John Garland May 02 '20 at 08:44
  • 1
    If you don't need the previous R version anymore, you may consider to delete the user library of the previous version: `C:/R-PKGS/win-library/3.6/`. Note to make a backup of this folder before deleting anything. – tpetzoldt May 02 '20 at 09:11
  • Tanks @tpetzoldt !`I didn't realize that `rtools40` was a package. Based on your suggestion I have done 2 thing: 1) created a new directory for downloaded packages `c:/R-PKGS/win-library/4.0` , 2) tried to install the package `rtools40` . However when I tried to install the `rtools40` package I get this error message: ` install.packages("rtools40") Installing package into ‘C:/R-PKGS/win-library/4.0’ (as ‘lib’ is unspecified) Warning in install.packages : package ‘rtools40’ is not available (for R version 4.0.0) ` – Andrés Lagerlöf May 02 '20 at 13:23
  • 1
    `rtools40` is the compiler set, needed on Windows if you want to install packages from source. It is not a regular R package, download and instructions are found [here](https://cran.r-project.org/bin/windows/Rtools/). – tpetzoldt May 02 '20 at 15:33
  • Thanks again @tpetzoldt it worked beautifully! You really saved my day! I'm very happy for your help. By the way, I also changed the package library as you suggested, thanks for that too! – Andrés Lagerlöf May 02 '20 at 18:54
  • I forgot...thank you @JohnGarland for your help too! – Andrés Lagerlöf May 02 '20 at 19:03

1 Answers1

1

R 4.0 on Windows is accompanied with a new tool set rtools40 that can be installed separately. The tool set contains compilers and other programming tools to install source code packages on Windows, while the compilers are usually already available on Linux systems. The tool set can be installed from CRAN, but it is usually not necessary, if only pre-compiled "binary packages" are installed.

An additional confusion can sometimes occur if packages from different versions of R are installed in the same folder, the so-called "personal library", in Windows by default:

c:\users\<username>\R\win-library

... or another user-specified folder. After updating to a new R version, it can be a good idea to clean up older win-libraries. Make sure, that the folders do not contain valuable personal data.

tpetzoldt
  • 5,338
  • 2
  • 12
  • 29