BTW I just noticed the alternative approach of searching through the
warnings, used at
https://github.com/Bioconductor/bioc_docker/blob/5be6d37ded4f97995640cbb3a7d201165234b1e4/src/core/install.R.in#L42
:

if (!is.null(warnings()))
{
    w <- capture.output(warnings())
    if (length(grep("is not available|had non-zero exit status", w)))
        quit("no", 1L)
}


On Tue, Jan 22, 2019 at 10:19 AM Levi Waldron <lwaldron.resea...@gmail.com>
wrote:

> I opened an issue on BiocManager (
> https://github.com/Bioconductor/BiocManager/issues/39) somewhat related
> to Sean's recent post, about what BiocManager::install() should return, and
> it occurs to me that I should mention it here too for feedback:
>
> > Having `BiocManager::install()` return the "pkgs" argument is not
> especially useful. Could it instead return success/error codes? Otherwise,
> how can you tell in a script whether the requested packages were installed
> successfully or not?
>
> The most basic return value I can think of would be like `require()`, TRUE
> if successful and FALSE if unsuccessful. More sophisticated behavior could
> give different error codes for different failures, although I don't know
> how difficult that would be to implement. This came up from wanting to test
> a Docker container for ability to install many different packages within
> it, and doing this by making a (hacked and specific to my purpose of
> installing/testing one package at a time) wrapper around
> `BiocManager::install()` that uses require() to test whether the
> installation was successful. That said, the workaround was not that
> difficult and it's probably not a priority for too many other users if
> you're hesitant to change the return value of BiocManager::install().
>
> installcheck <- function(x){
>   if (x %in% installed.packages())
>     return(TRUE)
>   BiocManager::install(x, ask=FALSE, update=FALSE)
>   res <- require(x, character.only = TRUE)
>   detach(paste0("package:", x), unload=TRUE, character.only = TRUE)
>   return(res)
> }
>
>
>

-- 
Levi Waldron
http://www.waldronlab.io
Associate Professor of Biostatistics    CUNY School of Public Health
US: +1 646-364-9616                                           Skype:
levi.waldron

        [[alternative HTML version deleted]]

_______________________________________________
Bioc-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/bioc-devel

Reply via email to