I'm maintaining an openCPU (R API) instance with frequent package updates. OpenCPU (sensibly) separates its own core packages into different folders, so that they aren't accidentally broken out of the lockstep with the installed version.
However, this can lead to duplicated packages being installed in the user folder which, then again, leads to errors when the openCPU API tries to unload and reattach the package to get the newer version. I frequently cause these sorts of problems when trying to update packages.
I usually check for them using this snippet.
ocpubasics <- rownames(installed.packages(lib.loc ="/usr/lib/opencpu/library"))
userpkgs <- rownames(installed.packages(lib.loc="/usr/local/lib/R/site-library"))
(dupe_pkgs <- userpkgs[ userpkgs %in% ocpubasics])
remove.packages(dupe_pkgs, lib="/usr/local/lib/R/site-library")
However, this doesn't catch all cases (because they are five library paths) and also removes duplicates that aren't mismatched for version (which don't really hurt and are sometimes necessary for a package to be installed). So, I'm wondering if someone has written a function which, given a vector of library paths, checks whether any package has a mismatched version installed in a different library path.