Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fixed Cargo example not working for multiple archs#1726

Open
Melchizedek6809 wants to merge 4 commits into
actions:mainfrom
Melchizedek6809:fix-cargo-example-multiple-archs
Open

Fixed Cargo example not working for multiple archs#1726
Melchizedek6809 wants to merge 4 commits into
actions:mainfrom
Melchizedek6809:fix-cargo-example-multiple-archs

Conversation

@Melchizedek6809
Copy link
Copy Markdown

Added runner.arch to the cache key in the Cargo example since otherwise an arm runner might pull an x86 cache which breaks the build. I got the following error without this fix:

/home/runner/work/_temp/98f299c6-8f8f-4624-b041-55b989a1682b.sh: line 1: /home/runner/.cargo/bin/cargo: cannot execute binary file: Exec format error

Description

It's just a change to the Rust/Cargo example since the action works quite well it's just that the key used in the example does not consider the architecture of the runner which at least for Rust/Linux is quite important.

Motivation and Context

Should help others since they might run into the same error as I did when just copy-pasting the example code, I for example just blindly assumed that runner.os might be something like "ubuntu-24.04" or "ubuntu-24.04-arm" to distinguish between the different architecture.

How Has This Been Tested?

Added the runner.arch part to the cache key for my Rust project and now

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation (add or update README or docs)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Didn't run the test suite since I only changed a single line in the docs / EXAMPLES.md file.

Copilot AI review requested due to automatic review settings March 1, 2026 12:52
@Melchizedek6809 Melchizedek6809 requested a review from a team as a code owner March 1, 2026 12:52
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the Rust/Cargo caching example to avoid cross-architecture cache restores (e.g., ARM runners restoring x86 caches), which can break builds when cached binaries are architecture-specific.

Changes:

  • Modify the Cargo example cache key to incorporate runner architecture in addition to OS and Cargo.lock hash.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread examples.md Outdated
@herrernst
Copy link
Copy Markdown

Shouldn't runner.arch be added to the cache key in all examples that build native objects, e.g. also Swift?

@Melchizedek6809
Copy link
Copy Markdown
Author

@herrernst Probably, but I haven't done any Swift development and I didn't want to add untested instructions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants