I am working on building an R package in RStudio. I am using R version 4.5.0 and RStudio version 2024.12.1 Build 563 on Ubuntu 24.04.2 LTS. When I install my package from the "install" button (which should run R CMD INSTALL --preclean --no-multiarch --with-keep.source<pkg>) in RStudio, I am intermittently getting a lazy-load database error and a warning message about the package being corrupt. This happens when I hit "install" when the package is loaded and data generated by the package is loaded. With a fresh R instance, it doesn't occur.
Error: lazy-load database '/home/user/R/x86_64-pc-linux-gnu-library/4.5/mypackage/R/mypackage.rdb' is corrupt
In addition: Warning message:
internal error 1 in R_decompress1 with libdeflate
I can fix it by running .rs.restartR(), and my package runs as expected, but I would prefer to find the root cause and fix it. I checked to see if I can recreate the error with packages from CRAN as well as a package that has passed CRAN checks that I developed previously, and I cannot recreate the error in either of these packages.
library()or similar function), R caches some things about the package. When the meta files of the package (.rdb, etc) change because you install it again, the file is changed underneath and R's recall of the file (indexing, etc) changes, it complains like this. I've seen this for ... a long time, and I've never found nor seen a way to work around it other than restarting R. It is frustrating. (And it is not related to the RStudio IDE.)