问题
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:
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.
来源:https://stackoverflow.com/questions/61556412/error-message-when-installing-xml2-r-package