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.

Permission denied creating tar for Apt files

See original GitHub issue

Based on @joshmgross’s latest comment in https://github.com/actions/cache/issues/133#issuecomment-629381394, here’s my use case, same as @evandrocoan https://github.com/actions/cache/issues/133#issuecomment-602695437

caching Apt list and package files in Ubuntu

Example workflow

The Apt step here takes about 35 seconds without caching. I’m hoping the cache will improve that. I’m also not 100% sure about the paths because I haven’t been able to test it yet.

      - name: Use Apt lists cache
        uses: actions/cache@v1
        with:
          path: /var/lib/apt/lists
          key: ${{ runner.os }}-apt-lists
      - name: Use Apt packages cache
        uses: actions/cache@v1
        with:
          path: /var/cache/apt
          key: ${{ runner.os }}-apt-packages
      - name: Install Apt dependencies
        run: |
          sudo apt-get update
          sudo apt-get install -y liblua5.1-dev luarocks

Error during post job

Post job cleanup.
/bin/tar -cz -f /home/runner/work/_temp/207e89c2-b0e5-4443-915a-2eafc37bc59b/cache.tgz -C /var/cache/apt .
/bin/tar: ./archives/partial: Cannot open: Permission denied
/bin/tar: ./archives/lock: Cannot open: Permission denied
/bin/tar: Exiting with failure status due to previous errors
[warning]Tar failed with error: The process '/bin/tar' failed with exit code 2

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:10
  • Comments:15 (5 by maintainers)

github_iconTop GitHub Comments

7reactions
AJMansfieldcommented, Feb 4, 2021

I was able to at least successfully save a cache of the downloaded .deb packages with this step:

      - name: Cache APT packages
        uses: actions/cache@v2
        with:
          path: |
            /var/cache/apt/archives/**.deb
            !/var/cache/apt/archives/partial
            !/var/cache/apt/archives/lock
          key: ${{ runner.os }}-apt

However, when attempting to restore this cache, the attempt to extract these cached files still results in Cannot open: Permission denied errors for each file:

Received 0 of 85361645 (0.0%), 0.0 MBs/sec
Received 71303168 of 85361645 (83.5%), 34.0 MBs/sec
Received 85361645 of 85361645 (100.0%), 35.8 MBs/sec
Cache Size: ~81 MB (85361645 B)
/bin/tar --use-compress-program zstd -d -xf /home/runner/work/_temp/6cb673f4-802b-4627-a69c-fc30b46f495f/cache.tzst -P -C /home/runner/work/haxe/haxe
/bin/tar: ../../../../../var/cache/apt/archives/autopoint_0.19.8.1-6ubuntu0.3_all.deb: Cannot open: Permission denied
/bin/tar: ../../../../../var/cache/apt/archives/bubblewrap_0.2.1-1ubuntu0.1_amd64.deb: Cannot open: Permission denied
 ⋮
 ⋮ (50 more lines omitted)
 ⋮
/bin/tar: ../../../../../var/cache/apt/archives/x11proto-randr-dev_2018.4-4_all.deb: Cannot open: Permission denied
/bin/tar: ../../../../../var/cache/apt/archives/x11proto-xinerama-dev_2018.4-4_all.deb: Cannot open: Permission denied
/bin/tar: Exiting with failure status due to previous errors
Warning: Tar failed with error: The process '/bin/tar' failed with exit code 2

If we could just have an option for running the /bin/tar command as sudo, that would make this tool significantly easier to use for caching system packages (like those installed by apt).

4reactions
chris-martincommented, Jul 2, 2021

I have a workflow that opens a Nix shell. It has a lot of small dependencies, and it takes about 4 minutes to download them from various Nix binary caches. Seems like it would be faster to restore from github’s cache. Is there some reason the restore can’t just run as root?

Read more comments on GitHub >

github_iconTop Results From Across the Web

"Cannot open: Permission denied" when creating a tar file
The problem is that you are executing the command inside /usr/src to which you do not have write permissions with your credentials.
Read more >
How to fix 'permission denied' error in Linux? [Solutions]
Every file and directory has some permission or privilege (read, write, or execute) associated with them. If you are not authorized to access ......
Read more >
NVM: Getting Permission denied with nvm install command
Posted an issue to nvm's repo. Turns out the problem was with curl and that I had installed it with snap instead of...
Read more >
How to Fix Shell Script Permission Denied Error in Linux
To fix the permission denied error in Linux, one needs to change the file permission of the script. Use the “chmod” (change mode)...
Read more >
tar creates 0-byte files and issues permission denied errors
yml: Cannot close: Permission denied tar: perl-5.30.1/.lgtm.yml: Cannot utime: Permission denied ... it goes on and on for every file. I think ...
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