Dependency package "package_name" not available
Unselecting the circled option in Project Options > Build Tools dialogue solves this problem, although I'm not quite clear on why:
When I had the same problem, it was caused by a problem in the DESCRIPTION file.
The line starting with Depends:
had the dependency package listed in the wrong case (e.g. Ggplot2
instead of ggplot2
)
I hope you don't need this fix anymore, but it might be useful for someone else.
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"’