error when loading packages

I have been using R(Studio) for a couple of months and never had an issue, but this morning I used the RStudio wizard to update all packages that needed it and now when I try to load certain packages I get the following error:

library(ggplot2)
Error: package or namespace load failed for ‘ggplot2’ in get(method, envir = home):
 lazy-load database 'C:/Users/drewh/OneDrive/Documents/R/win-library/4.1/ggplot2/R/ggplot2.rdb' is corrupt
In addition: Warning messages:
1: In .registerS3method(fin[i, 1], fin[i, 2], fin[i, 3], fin[i, 4],  :
  restarting interrupted promise evaluation
2: In get(method, envir = home) :
  restarting interrupted promise evaluation
3: In get(method, envir = home) : internal error -3 in R_decompress1

How can I fix this? Thanks in advance!

R has problems with cloud-synced folders (OneDrive in your case), I recommend you to set your package library in a non-synced folder.

You can change the default library folder by setting your R_LIBS_SITE environmental variable in a .Reviron or .Rprofile file. For example:

# In a .Renviron file you can set it by adding a line like this one with the desired location 
R_LIBS_SITE="C:\\Program Files\\R\\R-4.1.2\\library"

For a more detailed explanation, you can read this blog post

1 Like

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.