Existing cache cannot be restored
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 5.6k
- Forks
- 1.6k
- PR merge metrics
- No merged PRs in 30d
Description
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 https://github.com/actions/cache/issues/1665)
Attached are the log files from 3rd workflow run (created with the GHA debug diagnostics turned on): logs_47695047952.zip
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the workflow_dispatch job using the shown actions/cache@v4 configuration and the fixed Ronly-Main-123456789 key. Inspect the linked run logs and attached debug diagnostics to determine why an existing cache is not restored; done means the cache is restored on later runs without a duplicate-save error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- github-actions, r
- Domain
- ci-cd, devops
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100