Package ‘XXX’ was installed before R 4.0.0: please re-install it
A zip file is a pre-built binary package for use on Windows, not a source package. Installing it with install.packages(*, type="source")
won't make a difference. You'll need to contact the person/people who wrote these packages to build them again for R 4.0, or provide you with the real source -- this will usually be a .tar.gz
file.
All packages need to be reinstalled under the new version (4.0). I had to first remove and then reinstall all the packages.
The following worked for me:
# check your package library path
.libPaths()
# grab old packages names
old_packages <- installed.packages(lib.loc = "/Library/Frameworks/R.framework/Versions/3.6/Resources/library")
old_packages <- as.data.frame(old_packages)
list.of.packages <- unlist(old_packages$Package)
# remove old packages
remove.packages( installed.packages( priority = "NA" )[,1] )
# reinstall all packages
new.packages <- list.of.packages[!(list.of.packages %in% installed.packages()[,"Package"])]
if(length(new.packages)) install.packages(new.packages)
lapply(list.of.packages,function(x){library(x,character.only=TRUE)})
This issue is likely to happen when R is reading from an old directory, e.g. pre R 4.0.x .
Here is a few possible ways to fix this:
- Check your
.libPaths()
- R could be reading packages from a R 3.x.x library, which would produce the error you are getting. Alternatively, try creating a new library directory (this is very likely to fix the issue). update.packages(ask=FALSE, checkBuilt=TRUE)
(which you have already tried)- Remove previous installations of R, and their associated directories.