Dependency package “package_name” not available

后端 未结 4 1545
生来不讨喜
生来不讨喜 2021-01-17 20:40

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

4条回答
  •  误落风尘
    2021-01-17 20:46

    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"’
    

提交回复
热议问题