Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setup-renv isn't caching R packages when RENV_CONFIG_PAK_ENABLED: true #900

Closed
gadenbuie opened this issue Aug 5, 2024 · 4 comments · Fixed by #905
Closed

setup-renv isn't caching R packages when RENV_CONFIG_PAK_ENABLED: true #900

gadenbuie opened this issue Aug 5, 2024 · 4 comments · Fixed by #905
Labels
bug an unexpected problem or unintended behavior

Comments

@gadenbuie
Copy link

Describe the bug

I'm using the setup-renv action with RENV_CONFIG_PAK_ENABLED set to true. Unless I'm missing something, the package library isn't included in the cache and packages are always installed fresh with each run.

- name: 📦 Install dependencies with renv
  uses: r-lib/actions/setup-renv@v2
  env:
    RENV_CONFIG_PAK_ENABLED: true
  with:
    cache-version: 2

To Reproduce

Here are two subsequent runs of the same workflow, both spend ~10 minutes installing packages despite the cache hit.

  1. https://github.com/posit-conf-2024/level-up-shiny/actions/runs/10239407197/job/28324954289 (13m 49s)
  2. https://github.com/posit-conf-2024/level-up-shiny/actions/runs/10239778904/job/28325757466 (14m 46s)

Expected behavior

I was expecting the package library to be included in the cache.

Additional context

Here are a few relevant log lines:

echo "RENV_PATHS_ROOT=/home/runner/work/_temp/renv" >> $GITHUB_ENV
  shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
  env:
    GITHUB_TOKEN: ***
    GH_TOKEN: ***
    GITHUB_PAT: ***
    BUNDLE_EXT: linux-amd64.deb
    R_LIBS_USER: /home/runner/work/_temp/Library
    TZ: UTC
    _R_CHECK_SYSTEM_CLOCK_: FALSE
    NOT_CRAN: true
    RENV_CONFIG_PAK_ENABLED: true
# ... snip ...
Cache Size: ~15 MB (15681114 B)
/usr/bin/tar -xf /home/runner/work/_temp/3beeaa8e-c7bd-4e38-a6f4-337568925cab/cache.tzst -P -C /home/runner/work/level-up-shiny/level-up-shiny --use-compress-program unzstd
Cache restored successfully
Cache restored from key: Ubuntu 22.04.4 LTS-R version 4.4.1 (2024-06-14)-2-fdd42af88e931ce1a46f09[91](https://github.com/posit-conf-2024/level-up-shiny/actions/runs/10239778904/job/28325757466#step:5:96)e3efb3f513b4abae58b410ca640958cac33f917e
# ... snip ....
- One or more packages recorded in the lockfile are not installed.
- Use `renv::status()` for more details.
i Loaded project root .Rprofile.
The following package(s) will be installed:
- pak [0.7.2]
These packages will be installed into "~/work/level-up-shiny/level-up-shiny/renv/library/linux-ubuntu-jammy/R-4.4/x86_64-pc-linux-gnu".

# Installing packages --------------------------------------------------------
- Installing pak ...                            OK [linked from cache]
Successfully installed 1 package in 8.3 milliseconds.

✔ Updated metadata database: 2.95 MB in 9 files.

ℹ Updating metadata database
✔ Updating metadata database ... done

 
→ Will install 124 packages.
→ Will download [118](https://github.com/posit-conf-2024/level-up-shiny/actions/runs/10239778904/job/28325757466#step:5:124) CRAN packages (83.69 MB).
→ Will download 6 packages with unknown size.
@gadenbuie gadenbuie added the bug an unexpected problem or unintended behavior label Aug 5, 2024
@gaborcsardi
Copy link
Member

Where is the package library in this case?

@gadenbuie
Copy link
Author

I'm guessing it's in

~/work/level-up-shiny/level-up-shiny/renv/library/linux-ubuntu-jammy/R-4.4/x86_64-pc-linux-gnu

from the log messages, although I don't know exactly. I can say I'm using a standard renv::init() and the only change I made to r-lib/actions/setup-renv@v2 was to add the RENV_CONFIG_PAK_ENABLED: true.

@gadenbuie
Copy link
Author

gadenbuie commented Aug 5, 2024

Yeah, caching renv/library is enough, e.g.

- name: Restore package cache
  uses: actions/cache@v4
  with:
    key: ${{ runner.os }}-1-${{ hashFiles('renv.lock') }}
    restore-keys: ${{ runner.os }}-1-
    path: renv/library

(I realized afterwards that runner.os isn't the best choice, maybe runner.name would be better. Actually, runner.os is probably fine for my use case and is definitely better than runner.name.)

gaborcsardi added a commit that referenced this issue Aug 7, 2024
Copy link

This issue has been automatically locked. If you believe you have found a related problem, please file a new issue and include a link to this issue

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug an unexpected problem or unintended behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants