Skip to content

Commit f481f30

Browse files
committed
fix: prevent duplicate cross installation when cache restored
Issue: Cache restore-keys can restore from partial match (e.g., 'Linux-cross-') but cache-hit is only 'true' for exact key matches. This caused the install step to run even when cross binary was already cached, resulting in error: 'binary cross already exists in destination' Fix: Add explicit check for cross binary existence before attempting install Uses 'command -v cross' to detect if binary is available regardless of how it was restored (exact cache hit or restore-keys match) This ensures the install step only runs when cross is truly not available.
1 parent cc10e79 commit f481f30

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

.github/actions/setup-cross-compilation/action.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,19 @@ runs:
2727
restore-keys: |
2828
${{ runner.os }}-cross-
2929
30+
- name: Check if cross is already installed
31+
id: check-cross
32+
shell: bash
33+
run: |
34+
if command -v cross &> /dev/null; then
35+
echo "installed=true" >> $GITHUB_OUTPUT
36+
echo "cross is already installed: $(cross --version)"
37+
else
38+
echo "installed=false" >> $GITHUB_OUTPUT
39+
fi
40+
3041
- name: Install cross
31-
if: steps.cache-cross.outputs.cache-hit != 'true'
42+
if: steps.check-cross.outputs.installed != 'true'
3243
shell: bash
3344
run: |
3445
# Install cross from crates.io (stable release)

0 commit comments

Comments
 (0)