removing old versions of packages

I am using rstudio 1.4.904. Reviewing the installed packages, I find that several of them are installed twice in different folders and of different versions. Two of those folders, / usr / lib / R / library and / lib / R / site-library have root as owner and user, the other folder / home / hugo / R / x86_64-pc-linux-gnu-library / 4.0 has as owner and user hugo.
When from RStudio I try to remove a package located in the root folders, the command is executed without providing an error message, but the package remains in those folders.
I can remove the existing duplicate packages from the root folders from the command line, but I don't know if RStudio has its own database of installed packages, because if this is the case, it would be generating a problem for RStudio.
My question is: how can I remove duplicate packages from folders owned by root? In my opinion, in the R installation, packages should only be stored in the root folders, if you are working on a multi-user computer or on a server. In the case of a computer with only one user, the installation of R and RStudio should only place in the root folders, the executables and minimum packages necessary for R and RStudio to run.

Hi @hubabe,
Check out help("remove.packages").
BUT beware removing packages from the System library as you may end up with a non-functioning R version and will need to re-install from scratch.


I ran rstudio as administrator and it uninstalled the old version of a package. Thanks for your suggestion!

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.

Have you tried running RStudio with system administrator privileges?

Thanks for your reply. The problem is that in RStudio the packages are not removed when they are in a folder that belongs to the system administrator (root).
This is the command in RStudio:
remove.packages("dbplyr", lib="/usr/local/lib/R/site-library")
This is the result when the command ls -al / usr / local / lib / R / site-library | egrep 'd? plyr' on the ubuntu 20.04 command line:
~/RStudio/R_tutorial$ ls -al /usr/local/lib/R/site-library | egrep 'd?plyr'
drwxrwxr-x 7 root staff 4096 feb 22 2020 dbplyr
drwxrwxr-x 8 root staff 4096 jul 8 17:48 plyr
As can be seen, the dbplyr package has not been removed.
The question is: how can a package located in a folder belonging to the system administrator be removed from RStudio?