question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cache action shouldn't use first `tar` on the path

See original GitHub issue

The save and restore steps use the first tar on the path: https://github.com/actions/cache/blob/4809f4ada49f99628c256b84f23798ced8214a3c/src/save.ts#L64

This can cause problems if another step modifies the path so that a different version of tar is found first. For example, in this workflow, I installed R and Rtools, which added C:/Rtools/bin to the path. There is a copy of tar.exe in there, as well as gzip.exe. However, when actions/cache tries to use tar, it errors out saying it can’t find gzip. I’m not sure why exactly that error happens, since gzip is in the same directory. But it seems to me that actions/cache shouldn’t even try to use that copy of tar in the first place – it should always use the same copy of tar, no matter what other steps are used in the workflow.

Here’s the error:

Post job cleanup.
C:\Rtools\bin\tar.exe -cz --force-local -f d:/a/_temp/96241c04-a852-4c66-8b28-aae83ff432c1/cache.tgz -C d:/a/_temp/Library .
tar (child): gzip: Cannot exec: No such file or directory
tar (child): Error is not recoverable: exiting now
/Rtools/bin/tar: d\:/a/_temp/96241c04-a852-4c66-8b28-aae83ff432c1/cache.tgz: Cannot write: Broken pipe
/Rtools/bin/tar: Child returned status 2
/Rtools/bin/tar: Error is not recoverable: exiting now
[warning]The process 'C:\Rtools\bin\tar.exe' failed with exit code 2

https://github.com/wch/gha/commit/b407b89c2865433ae99dc88f39830437cbd01887/checks?check_suite_id=346434710#step:22:8

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:12 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
pdotlcommented, Nov 16, 2022

Hi @wch @sammcj we are tracking this issue in #984. Please check the current proposal there and provide comments/feedback if any. Closing this as duplicate and tagging wontfix for doing any path related changes according to the current proposal.

1reaction
mzabaluevcommented, Mar 9, 2021

I think using tar from $PATH is non-workable in the long run. Not only you get all the problems associated with system-installed tar binaries: https://github.com/actions/virtual-environments/issues/2619, #301, #362, https://github.com/actions/toolkit/issues/479, to reference just a few, you invite trouble from any workflow that has overridden the path.

I think the right course of action is to settle on using GNU tar in every virtual environment, as it has proven to be the least problematic tar flavor on both Windows and Mac, and is already the default on Linux, and invoking the GNU tar binary by the absolute path. GNU tar is already provided in all three virtual environments supported by GitHub Actions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cache action shouldn't use first `tar` on the path - - Bountysource
Cache action shouldn't use first `tar` on the path ... This can cause problems if another step modifies the path so that a...
Read more >
Caching Android ndk fails with permission #1337 - GitHub
I understand position of actions/cache owners that action shouldn't use sudo tar everywhere because it could cause problems on self-hosted ...
Read more >
How do I cache steps in GitHub actions? - Stack Overflow
At the Cache NPM dependencies step, the action will check if there's an existing cache for the current key · If no cache...
Read more >
7 Github Actions Tricks I Wish I Knew Before I Started
#1: How to Use Github Action Triggers; #2: Reusable Workflows with Workflow Calls; #3: Speeding the Workflows with Caching and Artifacts ...
Read more >
GitLab CI: Cache and Artifacts explained by example
Instead of caching node_modules, consider caching node's caching directory instead. The difference is caching downloaded tar.gz files instead of ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found