I am using a non-standard .libPaths() in R to keep packages relatively separate for multiple purposes, ArchR is among the ones I installed in a custom path that are not listed in .libPaths() by default. When I use ArchR I do (ArchR and nabor is installed at ~/R/x86_64-pc-linux-gnu-library/ArchR in my case):
library('ArchR', lib.loc = '~/R/x86_64-pc-linux-gnu-library/ArchR')
library('nabor', lib.loc = '~/R/x86_64-pc-linux-gnu-library/ArchR')
Both run normally without error and sessionInfo() list both as loaded.
However ArchR still complains about nabor not available. The only solution is to
.libPaths(c('~/R/x86_64-pc-linux-gnu-library/ArchR/', .libPaths()))
I believe the error comes from R/HiddenUtils.R around line 15 in the requirePackage() function:
.requirePackage <- function(x = NULL, load = TRUE, installInfo = NULL, source = NULL){
if(x %in% rownames(installed.packages())){
if(load){
suppressPackageStartupMessages(require(x, character.only = TRUE))
}else{
return(0)
}
}else
....
}
Basically it is checking if the packages is listed by installed.packages(). In my case installed.packages() won't list nabor or ArchR since they are not in .libPaths(). An additionally check of return of require() inserted here should revolve this bug. If the package is already loaded or can be found by require(), then it does not matter whether its is in .libPaths() or not since it is definitely available for use. Pseudo code:
.requirePackage <- function(x = NULL, load = TRUE, installInfo = NULL, source = NULL){
if(load & !require(x, character.only = TRUE)){
stop('Package ', x, ' not found!')
} else if(load & require(x, character.only = TRUE)) {
suppressPackageStartupMessages(require(x, character.only = TRUE))
return(0)
}
I am using a non-standard
.libPaths()in R to keep packages relatively separate for multiple purposes,ArchRis among the ones I installed in a custom path that are not listed in.libPaths()by default. When I useArchRI do (ArchRandnaboris installed at~/R/x86_64-pc-linux-gnu-library/ArchRin my case):Both run normally without error and
sessionInfo()list both as loaded.However
ArchRstill complains aboutnabornot available. The only solution is toI believe the error comes from
R/HiddenUtils.Raround line 15 in therequirePackage()function:Basically it is checking if the packages is listed by
installed.packages(). In my caseinstalled.packages()won't listnabororArchRsince they are not in.libPaths(). An additionally check of return ofrequire()inserted here should revolve this bug. If the package is already loaded or can be found byrequire(), then it does not matter whether its is in.libPaths()or not since it is definitely available for use. Pseudo code: