Is there a way not to install R packages suggested by dependencies?

I’m using Travis-CI to test a package aimed for Bioconductor: https://travis-ci.com/BUStools/BUSpaRse/jobs/210146459. The package passed R CMD check and BiocCheck locally, but on Travis, the time limit of 50 minutes was exceeded. The vast majority of time spent was to install dependencies, but I found that many packages installed, such as edgeR, are never used in my package, but are suggested by Bioconductor dependencies of my package, such as plyranges, which depends on GenomicRanges, which suggests a lot of packages. I didn’t install some of those suggested packages locally and nothing went wrong, so I don’t think I need those packages.

So my question is, can I skip installing packages suggested by dependencies? If that’s possible, then the actual R CMD check can finish before the time limit is exceeded.

I don’t see any options in BiocManager documentation to skip “recommended” packages when installing. If you know a way, you can submit a pull request to https://github.com/travis-ci/travis-build/blob/master/lib/travis/build/script/r.rb that would add such an option.

Otherwise, to prevent the job from timing out, use a preliminary stage to warm up the cache.

It worked. The .travis.yml file is:

language: R
r: bioc-devel
bioc_check: true
sudo: false
cache: packages
jobs:
  include:
    - stage: prepare cache
      script: true
    - stage: test
r_github_packages:
  - BUStools/TENxBUSData

before_script:
  # ensure bioc-devel is being used
  - R -e 'BiocManager::install(version = "devel", ask=FALSE)'
  - R -e 'BiocManager::valid()'

Hello - I’m running into a similar situation and would like to be certain I understand exactly how your build stages function with respect to an R project. My questions are:

  1. what determines the code that executes in ‘prepare cache’? I dont see a definition in the R plugin (https://github.com/travis-ci/travis-build/blob/master/lib/travis/build/script/r.rb). Does it just run through the regular initialization code (install your project from github (determined by r_github_packages)), and then do nothing else?

  2. Because you specify your own project in r_github_packages, does this mean it install the version off master, and not necessarily the one from your PR or branch? That is probably usually fine since I imagine dependencies dont change much?

  3. Does travis still try to re-install all the dependencies in subsequent steps (I assume this is fast b/c they were installed already)? I assume it still tries to download the current version of your module and runs ‘R CMD build’?

  4. what exactly does “script: true” indicate here? is this telling it to run the default script for this stage (whatever that may be)?

Thanks,
Ben

To be honest, I don’t really understand what happens behind the scene either; I just tinkered around until it worked. The prepare cache step installs the R dependencies and caches them, not running R CMD check until the test stage. Then in the test stage, R CMD check actually doesn’t start immediately. It will take a while to get the cached packages ready, but that still saves a lot of time compared to installing from scratch so it does not time out. I haven’t tried the prepare cache state with multiple branches, since when I used it, my repo only has the master branch. As for the script: true, I’m not sure what it does exactly, but without it, the prepare cache stage will run R CMD check anyway and time out.

Only directed suggested dependencies of your packages are installed, not all suggested dependencies of all dependencies.

If you want to override the dependency installation step you should use custom code for the install: step. If you want to override the check steps override the script: step.

Imprint