Skip to content

Cache action shouldn't use first tar on the path #125

Closed

Description

@wch

The save and restore steps use the first tar on the path:

const tarPath = await io.which("tar", true);

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

Activity

  1. joshmgross commented on Dec 12, 2019

    @joshmgross
    Contributor

    Hey @wch, I'm not sure what that gzip issue is, but we're making a change to use BSD Tar on Windows from the System path: #126

    For Linux and macOS, I think it's still correct to use the tar that's on the PATH.

  2. wch commented on Dec 12, 2019

    @wch
    Author

    Thanks, great timing! I don't know what the gzip issue is either -- it works without a problem when I run tar locally -- but I'm glad to hear that it won't matter in the future.

    Just curious: why would you want to use tar from the PATH on the other platforms? I can imagine that causing problems, but I don't see how it would be beneficial.

  3. joshmgross commented on Dec 12, 2019

    @joshmgross
    Contributor

    why would you want to use tar from the PATH on the other platforms?

    If we don't get tar from the PATH, how do we know where tar is?

  4. wch commented on Dec 13, 2019

    @wch
    Author

    I don't know that much about how actions work internally but is it possible to store the PATH at the beginning of a workflow? Or perhaps use a tar npm package?

  5. joshmgross commented on Dec 18, 2019

    @joshmgross
    Contributor

    is it possible to store the PATH at the beginning of a workflow

    Not possible currently. Actions are essentially a node process (or container) started by the runner, and they're passed the environment in its current state. Using a modified PATH is how the setup actions work (ex. actions/setup-go) as they're taking a specified version of a tool and pre-pending it to the path so that subsequent actions will use that version.

    Or perhaps use a tar npm package?

    We've hit issues in the past with tar npm packages, and we currently don't have a great reason to use a separate package

  6. mzabaluev commented on Mar 9, 2021

    @mzabaluev

    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: actions/runner-images#2619, #301, #362, actions/toolkit#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.

  7. rfay commented on May 6, 2021

    @rfay

    GNU tar seems to be required on all platforms, and zstd has to be added as well on self-hosted machines. See #576

  8. github-actions commented on May 7, 2022

    @github-actions

    This issue is stale because it has been open for 200 days with no activity. Leave a comment to avoid closing this issue in 5 days.

  9. wch commented on May 7, 2022

    @wch
    Author

    Bump

  10. sammcj commented on Jun 2, 2022

    @sammcj

    Any progress with this?

  11. joshmgross commented on Jun 2, 2022

    @joshmgross
    Contributor

    I think the right course of action is to settle on using GNU tar in every virtual environment,

    We've had issues with GNU tar on Windows in the past, which is why we moved towards BSD Tar - #126

    I don't know that much about how actions work internally but is it possible to store the PATH at the beginning of a workflow?

    We could pass the tar path from the restore step to the save step so that we're using the same tar in both.

  12. lvpx commented on Nov 16, 2022

    @lvpx
    Contributor

    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.

  13. added
    duplicate
    wontfix
    on Nov 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:compressionduplicatewontfix

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions