Bioconductor / BiocManager

CRAN Package For Managing Bioconductor Packages
http://bioconductor.github.io/BiocManager/
73 stars 22 forks source link

checking for already installed does not respect lib argument #121

Open lshep opened 2 years ago

lshep commented 2 years ago

So I'm testing locally and I have an environment variable set up to specify a different installation path:

> .libPaths()
[1] "/home/shepherd/R-Libraries/4.2-Bioc3.15"      
[2] "/home/shepherd/R-Installs/bin/R-devel/library"

I need biocViews to be installed directly in the second location which it does not do because I assume its finding it in the first despite me explicitly asking for installation

> install("biocViews", lib=.libPaths()[2])
Bioconductor version 3.15 (BiocManager 1.30.16), R Under development (unstable)
  (2021-10-27 r81106)
Warning message:
package(s) not installed when version(s) same as current; use `force = TRUE` to
  re-install: 'biocViews' 

> system("ls /home/shepherd/R-Installs/bin/R-devel/library")
base   cluster    datasets  grDevices   lattice  methods  nnet      spatial  stats4    tools
boot   codetools  foreign   grid    MASS     mgcv     parallel  splines  survival  translations
class  compiler   graphics  KernSmooth  Matrix   nlme     rpart     stats    tcltk     utils

Granted I can do a force=TRUE to get around this but it seems like the checking should be limited if lib is given

LiNk-NY commented 2 years ago

Hi Lori, I think in general, .libPaths()[2] the default installation packages should be untouched but I am not familiar with your use case.

For one off installations, you can use install.packages

install.packages("biocViews", repos = BiocManager::repositories(), lib = .libPaths()[2])

or set an R_LIBS_USER=/home/shepherd/R-Installs/bin/R-devel/library environment variable so that the path is the only option.

When we check whether a package is up to date, we don't do it within each lib but across all libs as given by instPkgs <- install.packages(). And then we pass the lib argument to install.packages. So another option is to modify the .libPaths() but a bit cumbersome.

lshep commented 2 years ago

again -- i needed it to a specific path which I specified with lib but it wouldn't do it without a force =TRUE becasue it found it in a different lib

LiNk-NY commented 2 years ago

That's due to installed.packages checking in all your .libPaths(). If you want to restrict to one folder then a set up change with R_LIBS_USER should work. I'm not sure why you need it in the default R packages location but if you could explain, that would help.

A change considering lib as an input would have to modify installed.packages and other parts of the code and may be best resolved with setting the environment variable or modifying .libPaths(). This is not a typical use case AFAICT.

Note. The other option is to remove the biocViews installation in .libPaths()[1] before installing in the other location.

lshep commented 2 years ago

its specific to the single package builder and certain packages required for the SPB to run correctly being installed in the default location. Again it seemed to me wrong to look in all libPaths if a specific one is identified and passed on. I agree this should be the default behavior but I would think that if I'm checking for a package in a specified libPath than the check would be restricted to that location too.