I\'m getting a strange error when trying to build and reload in RStudio. In my description file I\'ve included a package that I have built and maintain within my organizatio
Brandon's solution did not work for me. However, I found that if one runs document after loading the package, then it doesn't throw an error. Also, even when it throws an error, it still seems to be updating the package. So one can work around it by running the code in another order.
I looked into the source code for the document function and tracked down the error message to a requireNamespace call. Turns out that the package was not missing at all, but it had an error in the .onLoad function call. This causes requireNamespace to return FALSE (package could not be loaded), same as if the package is not installed. So, the real issue is that the error message from document is incorrect in this particular case.
Example error:
Browse[2]> requireNamespace("thepackage")
Loading required namespace: thepackage
Failed with error: ‘.onLoad failed in loadNamespace() for 'thepackage', details:
call: some_function(., some_variable)
error: could not find function "some_function"’