cache: Tracking: Permission Errors when restoring and creating cache
Issue
Files not created by the local user may fail when restored from the cache as tar preserves file permissions. Permission errors can also occur when the current user does not have permissions to read files when creating the cache. This is likely just a Linux and/or macOS issue (all the reports are Linux)
Reports
- https://github.com/actions/cache/issues/11
- https://github.com/actions/cache/issues/117
- https://github.com/actions/cache/issues/130
- https://github.com/actions/cache/issues/131
Possible solutions
- Run
tar
withsudo
- What are the downsides of this approach?
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 17
- Comments: 42 (8 by maintainers)
Commits related to this issue
- Revert "CI: cache Cargo registry & index" This reverts commit e8448b23f7e59aa4a3ef5eb83e4ef28a607e6d83. GitHub Actions cache plugin Bug: https://github.com/actions/cache/issues/133 — committed to messense/mupdf-rs by messense 4 years ago
- Run tar with sudo [actions/cache#133] — committed to jwt27/cache by jwt27 4 years ago
- Change owner on .cargo dir to allow caching There is an issue with ownership currently for the cache action, see https://github.com/actions/cache/issues/133 for more information. Also see https://git... — committed to wayofthepie/gram-cli by wayofthepie 4 years ago
- Change owner on .cargo dir to allow caching There is an issue with ownership currently for the cache action, see https://github.com/actions/cache/issues/133 for more information. Also see https://git... — committed to wayofthepie/gram-cli by wayofthepie 4 years ago
- Change owner on .cargo dir to allow caching There is an issue with ownership currently for the cache action, see https://github.com/actions/cache/issues/133 for more information. Also see https://git... — committed to wayofthepie/gram-cli by wayofthepie 4 years ago
- Change owner on .cargo dir to allow caching There is an issue with ownership currently for the cache action, see https://github.com/actions/cache/issues/133 for more information. Also see https://git... — committed to wayofthepie/gram-cli by wayofthepie 4 years ago
- Change owner on .cargo dir to allow caching There is an issue with ownership currently for the cache action, see https://github.com/actions/cache/issues/133 for more information. Also see https://git... — committed to wayofthepie/gram-cli by wayofthepie 4 years ago
- Cache cargo-audit on CI closes #3399 See https://github.com/actions/cache/issues/133#issuecomment-599102035 for chown bit — committed to matklad/rust-analyzer by matklad 4 years ago
- Fix cargo audit caching See https://github.com/actions/cache/issues/133#issuecomment-599102035 for chown bit — committed to matklad/rust-analyzer by matklad 4 years ago
- Fix cargo audit caching See https://github.com/actions/cache/issues/133#issuecomment-599102035 for chown bit — committed to Veetaha/rust-analyzer by matklad 4 years ago
- fix cargo cache in ci see https://github.com/actions/cache/issues/133#issuecomment-599102035 — committed to huggingface/tokenizers by Pierrci 4 years ago
- Fix cargo audit caching See https://github.com/actions/cache/issues/133#issuecomment-599102035 for chown bit — committed to JoshMcguigan/rust-analyzer by matklad 4 years ago
- add permission denied fix to cargo cache in ci * https://github.com/actions/cache/issues/133\#issuecomment-599102035 — committed to dhenkel92/route53-dyndns by dhenkel92 4 years ago
- add cargo cache to test/style/build jobs (#14) * add cargo cache to test/style/build jobs * small change to trigger the pipeline * add permission denied fix to cargo cache in ci * https://gi... — committed to dhenkel92/route53-dyndns by dhenkel92 4 years ago
- github: remove workaround for bug 133 in actions/cache This removes the workaround for https://github.com/actions/cache/issues/133 which should be fixed now. — committed to mvo5/snappy by mvo5 4 years ago
- github: remove workaround for bug 133 in actions/cache This removes the workaround for https://github.com/actions/cache/issues/133 which should be fixed now. — committed to mvo5/snappy by mvo5 4 years ago
- github: remove workaround for bug 133 in actions/cache This removes the workaround for https://github.com/actions/cache/issues/133 which should be fixed now. — committed to bboozzoo/snapd by mvo5 4 years ago
- github: remove workaround for bug 133 in actions/cache This removes the workaround for https://github.com/actions/cache/issues/133 which should be fixed now. — committed to bboozzoo/snapd by mvo5 4 years ago
~/.cargo
is a symlink for/usr/share/rust/.cargo
, so the chown only changed the owner of the symlink. Appending a/
to the path (sudo chown -R $(whoami):$(id -ng) ~/.cargo/
) does fix it without requiring a cache invalidation.I worked around this using
sudo chown -R $(whoami):$(id -ng) ~/.cargo
to make~/.cargo
owned by the current user.So what’s the “correct” solution to this? I see all these commits saying that they’re removing workarounds, but we’re still experiencing this exact problem after our action moves some temp files (created as
-rw-------
by default) into our cache folder. Are we supposed to make our action run as another user (and if so, which and how?)? Is there extra config needed to make this action run as root? Should we give up and micro-manage permissions in the cache (that seems like the very workaround that those projects removed)?Might as well paste in all the links in case someome reads this...
I’m hitting this as well while trying to cache buildkit state exported from the
/var/lib/docker
dir of a buildx builder. Many files and directories are only readable by root, was a solution for people facing this problem in a context other thancargo
actually found before this was closed?For Rust projects the permissions issue was fixed (see https://github.com/actions/virtual-environments/issues/572#issuecomment-626624527) for Ubuntu. There still a problem with
tar
on WindowsWorks for me on Linux. The Windows run has worked too, restoring from an ante-fix cache.
A cache where root is still owner got used. I think tar sets the owner before trying to set time and permissions, so those fail. If you invalidate the cache, for example by changing the cache key, it should work.
Any updates on this? I also run into errors on cargo registry related cache (on rust)
We’re having the following problems in https://github.com/OpenEthereum/open-ethereum/pull/11528 this is a rust project and caching artifacts works properly only on macOS, on linux we get https://github.com/OpenEthereum/open-ethereum/runs/474579803#step:5:7
and on windows https://github.com/OpenEthereum/open-ethereum/pull/11528/checks?check_run_id=474579823#step:5:7
I was running into this, where caching had been working fine on the main Linux host, but simply moving the workflow into a container caused the cache saving step to fail with the following:
The path reported was consistent, but had nothing to do with the cache path. (It may have corresponded to the first entry of
ls -R
from the repository root, but I’m not exactly sure.)I was able to work around it by running
chmod -R a+rwx .
as the very last thing happening in the container. That grants (absolutely all) privileges back to the host’s user, so that the cache action can access whatever it needs.Note that simply enabling permissions for the path to be cached was not sufficient. I tired of experimenting before I could figure out exactly which permissions were and weren’t needed. I leave that exercise to someone else if their use case necessitates tighter security.
No, they’re individual Ubuntu VMs, see Docs: Cloud hosts for GitHub-hosted runners.
Files created by container actions, however, will likely be created by the
root
user.@joshmgross we’re seeing the issue at tauri-apps/tauri as well (also cargo-related): https://github.com/tauri-apps/tauri/pull/237/checks?check_run_id=364927646#step:7:9
@joshmgross I’m facing the same with gradle on all of Android projects (configured to run on Linux) Gradle wrapper doesn’t restore itself from cache. I’ll be able to add sample Inn a couple of hours.
Great point, I missed that difference. I’ve updated the issue title and description to cover both restore and creation.
It’s likely that the user account provisioned for hosted Windows runners has the necessary admin privileges, whereas Linux/macOS require
sudo
I don’t think this is an accurate description of the issue. If you look at my issue, it has this snippet:
This is when the tar file is being created, not when it is being unpacked; the problem comes because the current user does not have permissions to read files owned by root, separate from anything tar does. This is why I’m surprised it’s not an issue on Windows.