Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dependency package "package_name" not available

Tags:

r

devtools

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 organization. It's not on CRAN. Essentially, when I update the DESCRIPTION file (Depends: ...), I get this error:

==> devtools::document(roclets=c('rd', 'collate', 'namespace', 'vignette'))

Updating fczstudy documentation
Loading fczstudy
Error in (function (dep_name, dep_ver = NA, dep_compare = NA)  : 
  Dependency package surv3 not available.
Calls: suppressPackageStartupMessages ... <Anonymous> -> load_all -> load_depends -> mapply -> <Anonymous>
Execution halted

In this case, surv3 is a package that I maintain within my organization - I can confirm that it is indeed installed because I'm using it.

This doesn't seem to happen with other packages from CRAN. It just started a few days ago. It's not allowing me to import my package (surv3)

I'm really not sure how to debug this.

traceback() in the console after ctrl+shift+B returns nothing

Here is my sessionInfo():

R version 3.2.0 (2015-04-16)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 8 x64 (build 9200)

locale:
[1] LC_COLLATE=English_United States.1252 
[2] LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods  
[7] base     

other attached packages:
[1] surv3_1.01     knitr_1.11     fczstudy_0.1.0 dplyr_0.4.3   
[5] ggplot2_1.0.1 

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.1      assertthat_0.1   digest_0.6.8    
 [4] MASS_7.3-40      R6_2.1.1         grid_3.2.0      
 [7] plyr_1.8.3       gtable_0.1.2     DBI_0.3.1       
[10] magrittr_1.5     scales_0.3.0     stringi_0.5-5   
[13] lazyeval_0.1.10  reshape2_1.4.1   rmarkdown_0.8.1 
[16] proto_0.3-10     tools_3.2.0      stringr_1.0.0   
[19] munsell_0.4.2    yaml_2.1.13      parallel_3.2.0  
[22] colorspace_1.2-6 htmltools_0.2.6 
like image 984
Brandon Bertelsen Avatar asked Oct 30 '15 03:10

Brandon Bertelsen


People also ask

What do I do if R package is not available?

Make sure the package is released on CRAN You try to install them all, and one of the packages gives you this error. It's not uncommon for this error to happen simply because the package is not actually on CRAN. The package you're trying to install might be on GitHub or Bioconductor or any other repository.

Why can't I install packages in R?

Changing the configuration in R Studio to solve install packages issue. Go To Tools -> Global option -> Packages. Then uncheck the option “Use secure download method for HTTP”. For other RStudio issues refer to official Troubleshooting Guide here.


3 Answers

Another possible solution is to check if the package dependencies are up to date. I have the same problem with ggplot2, and when I tried to load the package, an error occurred because of the dependency package 'scales' was built in an R version with different internals. So the solution was to reinstall package scales.

So, you could try to reinstall all dependencies of the 'ggplot2' package.

like image 66
Enrique Del Callejo Canal Avatar answered Dec 29 '22 21:12

Enrique Del Callejo Canal


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"’
like image 31
CoderGuy123 Avatar answered Dec 29 '22 23:12

CoderGuy123


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.

like image 37
Tamás Bárász Avatar answered Dec 29 '22 22:12

Tamás Bárász