Skip to content

Existing cache cannot be restored #1666

@Yuri05

Description

@Yuri05

I have the GHA-workflow below, which installs R and some R packages on windows-latest and should cache the R packages directory.
The workflow is always triggered manually (workflow_dispatch) from the main branch of the repo (which is also the only branch in this repo).

Workflow yaml
name: Test Cache R

on:
  workflow_dispatch:

permissions:
  contents: read
  actions: write

env:
  GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

jobs:
  evaluation:
    runs-on: windows-latest
    env:
      R_LIBS_USER: ${{ github.workspace }}\RLibrary
    steps:
    - name: Checkout repository
      uses: actions/checkout@v4
    
    - name: Restore setup cache
      id: cache-setup
      uses: actions/cache@v4
      with:
        key: Ronly-Main-123456789
        path: |
          ${{ env.R_LIBS_USER }}

    - name: Setup R
      uses: r-lib/actions/setup-r@v2
      with:
        r-version: '4.3.1'
        use-public-rspm: true
        rtools-version: 'none'

    - id: install-cran-packages
      name: Install cran packages (NO CACHE FOUND)
      if: steps.cache-setup.outputs.cache-hit != 'true'
      run: |
        install.packages(c("remotes", "pak"))
      shell: Rscript {0}

    - name: Debug cached paths before save
      if: steps.cache-setup.outputs.cache-hit != 'true'
      run: |
        echo "Listing R library root: $R_LIBS_USER"
        if [ -d "$R_LIBS_USER" ]; then
          ls -l "$R_LIBS_USER" 
        else
          echo "R library directory missing"
        fi
      shell: bash

The first workflow run creates the cache as expected.

Screens: created cache

All following workflow runs (started again manually from the same main branch of the repo) however cannot restore from cache.
But the cache exists - which results in the error message when trying to save the cache again in the "Post restore" workflow step:

E.g. here is the result from the 2nd workflow run:
(The error message is misleading; in fact the cache for the given combination of {branch, key, version} exists - compare #1665)



Attached are the log files from 3rd workflow run (created with the GHA debug diagnostics turned on): logs_47695047952.zip

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions