cache icon indicating copy to clipboard operation
cache copied to clipboard

The process '/usr/bin/tar' failed with exit code 1 -- file changed as we read it

Open F-WRunTime opened this issue 1 year ago • 1 comments

There is not a clear approach on how to work around this or force it to tar up the files.

I've tried force killing the running process before calling actions/cache/save and it complains files are being changed. I don't understand how best to debug this but seems like with the compression program used.

There needs to be a verbose option to see what's happening under the hood to better understand why this fails the workflow.

/usr/bin/tar --posix -cf cache.tzst --exclude cache.tzst -P -C /home/github/actions-runner/_work/artifacts --files-from manifest.txt --use-compress-program zstdmt
/usr/bin/tar: artifacts/: file changed as we read it
Warning: Failed to save: "/usr/bin/tar" failed with error: The process '/usr/bin/tar' failed with exit code 1
Warning: Cache save failed.

Configuration used:

    - name: Save ${{ matrix.target }} Corpus
      if: always()
      uses: actions/cache/[email protected]
      with:
        path: ${{ github.workspace }}/artifacts
        key: ${{ matrix.target }}-corpus-${{ github.run_id }}

F-WRunTime avatar Dec 19 '24 06:12 F-WRunTime

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repository
        uses: actions/checkout@v4

      - name: Build artifacts
        run: |
          # Simulate a build process that creates artifacts
          mkdir -p artifacts
          echo "Example artifact" > artifacts/example.txt

      - name: Stop processes writing to artifacts
        run: |
          # Stop any processes that might be writing to the artifacts directory
          # Replace `your-process-name` with the actual process name
          pkill -f your-process-name || true

      - name: Copy artifacts to a temporary directory
        run: |
          mkdir -p /tmp/artifacts
          cp -r artifacts/* /tmp/artifacts/

      - name: Save artifacts to cache
        id: cache-artifacts
        uses: actions/cache/save@v4
        with:
          path: /tmp/artifacts
          key: ${{ matrix.target }}-corpus-${{ github.run_id }}

      - name: Debug cache save failure
        if: steps.cache-artifacts.outputs.cache-save-failed == 'true'
        run: |
          echo "Cache save failed. Retrying..."
          # Retry the cache save step
          mkdir -p /tmp/artifacts-retry
          cp -r artifacts/* /tmp/artifacts-retry/
          tar -cvf /tmp/cache.tzst --exclude cache.tzst -C /tmp/artifacts-retry . --use-compress-program zstdmt

ljluestc avatar Feb 10 '25 04:02 ljluestc