Skip to content

ArchR complains about nabor package not available even if nabor is loaded #2302

@JackieMium

Description

@JackieMium

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)
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions