Error in fetch(key) : lazy-load database - r

I don't know what is going on, everything was working great but suddenly I started to have this error message on the documentation:
Error in fetch(key) : lazy-load database '......descopl.rdb' is
corrupt
I removed almost all my code and build again then publish to Github, but when I use the other laptop to download the package, the package is being downloaded and loaded but I can't call any of the functions, and the documentation states that error.
I don't know what caused the problem, I am using roxygen to generate the documentation.
https://github.com/WilliamKinaan/descopl

It seems that the error arises when the package cannot be decompressed by R (as #rawr established, it is corrupt). This solutions have worked for me:
1) Check for possible errors in the creation of the .Rdb files
2) Try restarting your R session (e.g. .rs.restartR() if in RStudio)
3) The package might have been installed in your computer (even though it does not work). Remove it using ?remove.packages()

I have had this problem with roxygen2 as well. Couldn't see any problem with any of my functions. In the end deleting the .rdb file and then getting roxygen2 to rebuild it seemed to solve the problem.

I think the explanation for what is causing this is here.
It's related to devtools.
Per #Zfunk
cd ~/Rlibs/descopl/help
rm *.rdb
Restart R. Look at the help for the package again. Fixed!

I received this error after re-installing a library whilst another R session was running.
Simply restarting the existing R session(s) solved for me (i.e. running .rs.restartR() to restart the sessions)

If you are using R-studio:
1) ctrl+shift+f10 to restart r session
2) tools -> Check for package updates -> update all packages
3) library(ggmap)
Problem is solved.

Basically all answers require restarting R to resolve the issue, but I found myself in an environment where I really didn't want to restart R.
I am posting here a somewhat hack-ish solution suggested by Jim Hester in a bug report about the lazy-load corruption issue.
The gist of it is that the package may have some vestigial S3 methods listed in session's .__S3MethodsTable__. environment. I don't have a very systematic way of identifying which S3 methods in that environment come from where, but I think a good place to start is the print methods, and looking for S3method registrations in the package's NAMESPACE.
You can then remove those S3 methods from the .__S3MethodsTable__. environment and try again, e.g.
rm(list="print.object", envir = get(".__S3MethodsTable__.", envir = baseenv()))
You may also need to unload some DLLs if some new messages come up like
no such symbol glue_ in package /usr/local/lib/R/site-library/glue/libs/glue.so
You can check getLoadedDLLs() to see which such files are loaded in your session. In the case of glue here, the following resolved the issue:
library.dynam.unload('glue', '/usr/local/lib/R/site-library/glue')

I got this error on RStudio on mac OS - updating all the packages and restarting r session did the trick.

Related

Circularity detected when running (vega:load-vega-examples)

When I load the vega-lite data sets using
(vega:load-vega-examples)
I get the following error:
Could not REQUIRE CL-DATE-TIME-PARSER: circularity detected. Please check your configuration
However, the examples appear to have loaded.
Also, before I installed cl-date-time-parser in quicklisp, I was getting an error message similar to:
Do not know how to REQUIRE CL-DATE-TIME-PARSER
Does anyone know how to get rid of these errors?
Many thanks!
The IMDB example requires cl-date-time-parser. I suspect that problem is that (require ...) only works when the library is in a location known to ASDF. In a new installation, this may not be the case. Now reported as issue #19.
Try loading the library with quicklisp and then rerunning load-vega-examples.

How do I edit an R package from GitHub that has already been cloned?

I have an R package, created by someone else that I have been made a collaborator on, that I want to work on and develop. I've already cloned the repository to my local computer through the Create Project > Clone from GitHub route in RStudio, and since then I've been editing the scripts, but not working with it as a package. As in, I had been adding functions and working on a Shiny interface, but not following any R package development rules (loading packages directly into the .R files, not updating the NAMESPACE, using roxygen2 conventions, etc.).
Everything I've read mentions devtools::install_github, but I don't want to install and use it, I want to edit it like I've been doing. I also want it to still be connected to Git (so I can continue to commit and pull from the remote server, once my collaborators make edits). I've tried devtools::load_all() and devtools::document(), but it gives me this warning:
Error in FUN(X[[i]], ...) :
bad restore file magic number (file may be corrupted) -- no data loaded
In addition: Warning messages:
1: In readChar(con, 5L, useBytes = TRUE) :
truncating string with embedded nuls
2: file ‘file_example.rda’ has magic number 'X'
Use of save versions prior to 2 is deprecated
Do I need to delete my local copy and do something different to work with it as a package so that the functionality of roxygen2 and the NAMESPACE documentation will work correctly? Or is there an obvious reason for this error/something I'm missing about how to work with it as a package, how it is currently?
Thanks!
It looks like file_example.rda is corrupt
Can you just load it in R and check what it contains?
You could try:
tools::resaveRdaFiles( 'file_example.rda', compress='xz' )
And see if that saves it in a way that is acceptable?

How to troubleshoot Error: Could not find package root?

I am running the command: devtools::use_testthat()
and I get the error:
Error: Could not find package root.
Why this happens?
devtools appears now to require the user to setwd("~/path/to/package"), even if functions like devtools::release() have the pkg= parameter set correctly.
My problem was very similar, but running devtools::document(setwd(...)). The only thing that worked for me:
I copied the DESCRIPTION file from another package (https://github.com/filipezabala/voice);
I ran devtools::document(setwd(...)) again;
After that, I edited the DESCRIPTION file and ran again devtools::document(setwd(...)).

Weird issue while testing R package: package `[package name]` found more than once, using the first from [file path]

I'm working on a somewhat complex package (that I unfortunately can't share) that involves a Shiny app, and it an issue has surfaced where I'm getting these warnings when testing:
package [package name] found more than once, using the first from [file path]
In library(testthat) : package ‘testthat’ already present in search()
The first one occurs because I'm using system.file to pull a file in inst that I use for testing.
I've tried to do some debugging with .libPaths and by forcing system.file to go to the .libPaths default with the lib.loc argument, but that doesn't do anything.
I've tried uninstalling the package, which works because then there are not multiple results for find.package.
It seems like testthat adds the current directory to the library paths while it's running, and this creates the issue with system.file and consequently, find.package.
I'm really confused as to what's causing this. I'm combing through the changes I've made and I can't seem to find anything. Any ideas are helpful. I've tried googling this error messages and all that comes up is the source.
The issue here was with changing the option setting for verbose. That caused more output to result from the code, which broke a lot of tests. I hope this helps someone in the future.

Keep hitting the error ""loop_apply" not resolved from current namespace (plyr)" in ggplot2 with example codes

i keep hitting this error today and I already download the plyr from github but it still doesn't work. I restarted R-studio even my PC after installing plyr..
It appears the problem may be due to a change made to the way R resolves references to external DLLs, as mentioned halfway through the thread here.
Adding the parameter PACKAGE="plyr" to the .Call function call on line 12 of R/loop_apply.R in the source (clone from github), and then installing the package from that source (install.packages("<path to plyr source>", type="source", repos=NULL)) seems to fix it.

Resources