awalsh128 / cache-apt-pkgs-action

Cache APT packages in GitHub Actions
Other
205 stars 35 forks source link

Exec Format Error on ARM Runner with apt_query #126

Closed atilsensalduz closed 8 months ago

atilsensalduz commented 8 months ago

When utilizing a self-hosted runner with an ARM processor, an error is encountered with the following message:

/runner/_work/_actions/awalsh128/cache-apt-pkgs-action/latest/lib.sh: line 106: /runner/_work/_actions/awalsh128/cache-apt-pkgs-action/latest/apt_query: cannot execute binary file: Exec format error
Error: Process completed with exit code 126.

This issue is often associated with ARM processors, given the "Exec format error" message, but the exit code 126 suggests a potential permission problem. There's suspicion that the apt_query binary may not have the execute permission (exec) during its execution.

Suggested Solution: Consider adding a chmod +x apt_query command in the lib.sh script just before executing the apt_query binary. This step could ensure that the binary file has the necessary execution permissions.

koppor commented 8 months ago

It can be reproduced by using a BuildJet ARM runner,

Workaround: instead of @latest use @v1.3.1.

koppor commented 8 months ago

I think, the issue is that apt_query is a binary file compiled for x86. arm binaries are different. An arm platform cannot run (easily) x86 binaries. See https://opensource.com/article/21/1/go-cross-compiling for details.

atilsensalduz commented 8 months ago

Thanks, @koppor! Absolutely, we should build the apt_query binary for ARM architecture. We can then either dynamically select the correct binary in the shell script, or consider transitioning the GitHub Action method from Bash to Docker. By doing the latter, we could create an image that supports both ARM and AMD architectures. This way, we won't have to make any custom decisions at the script level and can seamlessly utilize both architectures.

awalsh128 commented 8 months ago

Thanks for the investigation and feedback. Totally agree that we can then dispatch at the action level for the right arch. I plan to move it all to Go so this is much more transparent (thanks again for the PR). I'll update this issue when I have some more time.