It seems actions/cache is not able to restore C++ artifacts in such a way that they can be used from the build.
We're using node.js source code directly as part of our app. Usually, nodejs build takes ~30mins. I want to improve our CI builds using actions/cache and cache whole node.js's source code along with build artifacts. The problem is that the second build throws an error as it is not able to execute one of cached binaries. It seems the binary is getting corrupted and it is no longer recognized.
It seems the problem is related to how actions/cache handles and processes provided input files.
It works if I manually create a zip, upload it to s3 and download it from the build.
I created a repo that demonstrates the problem - https://github.com/Fatme/cache-actions-issue
Hi, this is a weird one. It looks like that executable (mksnapshot) is getting corrupted so it's no longer recognized as an executable file on MacOS. This can be seen by running file <path>/mksnapshot. The original file type is Mach-O 64-bit executable x86_64 but becomes data after restore (which indicates the type isn't recognized).
This seems related to https://github.com/actions/cache/issues/403 where some .dylib files were being corrupted. That issue was fixed by installing GNU tar and seems to also fix this issue.
Please try adding the following to your workflow file before the cache step. It takes a few minutes to install GNU tar, but that might be worth it if it cuts down the 30 minutes to build nodejs.
- name: Install GNU tar
run: |
brew install gnu-tar
echo "/usr/local/opt/gnu-tar/libexec/gnubin" >> $GITHUB_PATH
We have an open issue to switch over to using GNU tar - https://github.com/actions/toolkit/pull/610.
Edit: If using a matrix strategy with multiple OS'es, here's a version of the step that will only run on macOS:
- name: Install GNU tar
if: runner.os == 'macOS'
run: |
brew install gnu-tar
echo "/usr/local/opt/gnu-tar/libexec/gnubin" >> $GITHUB_PATH
Hi @dhadka,
Thank you very much for looking into this!
I tested the provided workaround and it works!
It takes a few minutes to install GNU tar
Actually, the installation of GNU tar takes around 15-25 seconds on my side which is OK having in mind that it saves us more than 30 minutes skipping the native build part.
Closing given the workaround. Tracking permanent fix with https://github.com/actions/toolkit/issues/552.
Most helpful comment
Hi, this is a weird one. It looks like that executable (
mksnapshot) is getting corrupted so it's no longer recognized as an executable file on MacOS. This can be seen by runningfile <path>/mksnapshot. The original file type isMach-O 64-bit executable x86_64but becomesdataafter restore (which indicates the type isn't recognized).This seems related to https://github.com/actions/cache/issues/403 where some
.dylibfiles were being corrupted. That issue was fixed by installing GNU tar and seems to also fix this issue.Please try adding the following to your workflow file before the cache step. It takes a few minutes to install GNU tar, but that might be worth it if it cuts down the 30 minutes to build nodejs.
We have an open issue to switch over to using GNU tar - https://github.com/actions/toolkit/pull/610.
Edit: If using a matrix strategy with multiple OS'es, here's a version of the step that will only run on macOS: