Thanks to visit codestin.com
Credit goes to github.com

Skip to content

setup-r-dependencies action always reinstalls site-packages if no cache is available #814

@pascalgulikers

Description

@pascalgulikers

STOP

If you are debugging a failed build or have a question about GitHub Actions in
general do NOT open an issue here. Either post on the Actions sections of
the GitHub Community or the RStudio Community forums.

Open an issue here only if you have a bug in one of the
custom R specific actions themselves.

Describe the bug
setup-r-dependencies uses pak::lockfile_create() with no lib-parameter. Therefor it defaults to .Library which means only installed base packages are being detected and all (pre-)installed site-packages (.Library.site) are being ignored and will be reinstalled.
See:

pak::lockfile_create(

To Reproduce
We're using nightly built base images for Github actions with most used R packages already included so we can speed up the install dependencies step in our workflows. As caching is being stored on the runner and not on the base image itself, it's not being used unless you rerun the same workflow/branch. Initial runs don't have cache but the installed site-packages should be checked, this does not happen because of the mentioned finding (.Library only contains R base packages).

Continuous-Integration:
    runs-on: ubuntu-latest
    container:
      image: ***.dkr.ecr.eu-central-1.amazonaws.com/base-images/builder-r-latest:latest

Expected behavior
Installed site-packages should be checked, this does not happen because of the mentioned finding (.Library only contains R base packages). Therefor all site-packages will be downloaded from remote repositories like CRAN or RSPM

Additional context
Possible workaround is to install the extra packages in the base images in the .Library folder (in our case it's /usr/local/lib/R/library) instead of the .Library.site folder (/usr/local/lib/R/site-library).
A nicer solution is to specify .Library.site for the lib-parameter of the pak::lockfile_create() call here, like so:

pak::lockfile_create(
  c(deps, extra_deps),
  lockfile = ".github/pkg.lock",
  lib = .Library.site,
  upgrade = (${{ inputs.upgrade }}),
  dependencies = c(needs, (${{ inputs.dependencies }}))
)

relevant (tried) env-variables:
R_LIBS_USER="/usr/local/lib/R/site-library"
R_LIBS_SITE="/usr/local/lib/R/site-library"
R_LIB_FOR_PAK="/usr/local/lib/R/site-library"

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions