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

Issue with Saving Yarn Cache on Self-Hosted Runner #1113

Open
2 of 5 tasks
marouanechoukri31 opened this issue Jul 23, 2024 · 4 comments
Open
2 of 5 tasks

Issue with Saving Yarn Cache on Self-Hosted Runner #1113

marouanechoukri31 opened this issue Jul 23, 2024 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@marouanechoukri31
Copy link

marouanechoukri31 commented Jul 23, 2024

Description:
A problem occurred while saving the yarn cache using a self-hosted runner. The process works correctly on the hosted runner.

Error :

Failed to save: Unable to reserve cache with key node-cache-macOS-yarn-33259bc05a9ff84ddf70121c6ada6b7886b9a8e9721b785469c879d852cc411e, another job may be creating this cache. More details: Cache already exists.

Code :


- name: Use Node.js
  uses: actions/setup-node@v4
  with:
     node-version: '20.15.1'
     cache: 'yarn'

Action version:
Version 4

Platform:

  • Ubuntu
  • macOS
  • Windows

Runner type:

  • Hosted
  • Self-hosted

Tools version:

Node version : 20.15.1
Yarn version : 1.22.22

@marouanechoukri31 marouanechoukri31 added bug Something isn't working needs triage labels Jul 23, 2024
@gowridurgad gowridurgad self-assigned this Aug 5, 2024
@mahabaleshwars
Copy link

Hello @marouanechoukri31,
Thank you for creating this issue. We will investigate it and provide feedback as soon as we have some updates.

@gowridurgad
Copy link

Hi @marouanechoukri31, This issue typically occurs in the following scenarios:

Concurrent Jobs: Multiple jobs in the same workflow or different workflows are trying to create or reserve a cache with the same key simultaneously.

Duplicate Cache Key: The cache key being used is not unique enough, causing conflicts when another job has already created a cache with the same key.

To avoid this issue, you can try the following:

1. Ensure Unique Cache Keys: Modify the cache key to include more unique elements, such as a combination of job ID and timestamp. Here is an example of how you can modify the cache key to make it unique. This ensures that each job will have a unique cache key, reducing the likelihood of conflicts.

- name: Create unique cache file
  run: |
    echo "${{ github.run_id }}-${{ matrix.os }}-$(date +%s)" > .cache-key
- uses: actions/setup-node@v4
  with:
    node-version: 20.x
    cache: 'yarn'
    cache-dependency-path: |
      **/yarn.lock
      .cache-key

2. Implement actions/cache: Use the actions/cache action to handle caching directly.

 - name: Cache Yarn dependencies
        id: cache-yarn
        uses: actions/cache@v4
        with:
          path: /Users/runner/Library/Caches/Yarn/v6
          key: yarn-cache-${{ runner.os }}-${{ matrix.os }}-${{ hashFiles('**/yarn.lock') }}
          restore-keys: |
            yarn-cache-${{ runner.os }}-${{ matrix.os }}-

@gowridurgad
Copy link

Hi @marouanechoukri31, Just a gentle reminder regarding this issue, If you have any updates or need further assistance, Please let us know.

1 similar comment
@gowridurgad
Copy link

Hi @marouanechoukri31, Just a gentle reminder regarding this issue, If you have any updates or need further assistance, Please let us know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants