'R package was installed by version with different internals

On my Win 7 Ent x64 I installed RStudio R-3.4.2.

I installed few packages that I need (RPostgreSQL, sqldf, etc..) But when I'm executing code, these libraries give me errors:

library(RPostgreSQL)

Error: package ‘RPostgreSQL’ was installed by an R version with different internals; it needs to be reinstalled for use with this R version

In addition: Warning message: package ‘RPostgreSQL’ was built under R version 3.5.0

All of the packages are downloaded from CRAN. RPostgrSQL is 0.6-2 version.

I'm pretty sure that solution is quite simple, but I searched a lot and still cannot find the solution.



Solution 1:[1]

How did you install the package RPostgreSQL? If you used install.packages("RPostgreSQL") on your Windows it installed using binaries, which may have been built using a different R version. In your case, 3.5.0 vs 3.4.2.

Try using install.packages("RPostgreSQL", type="source"). This way your machine will compile the package from source using your version of R, and it should work.

If the package needs C/C++/Fortran compilation, you will als need RTools installed on your machine.

Solution 2:[2]

You can try to find all packages installed with the old version R like this:

grep 'Built: R 3.4' /usr/local/lib/R/site-library/*/DESCRIPTION > temp

and then you can uninstall the packages with remove.packages()

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 RaoniRAO
Solution 2 MonsieurWave