Skip to content

Commit 9e79c4e

Browse files
committed
Fix Cargo.lock version 4 compatibility in GitHub Actions workflows
1 parent a0e992f commit 9e79c4e

File tree

4 files changed

+52
-3
lines changed

4 files changed

+52
-3
lines changed

.github/workflows/README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,10 @@ If you encounter Cargo lock file version compatibility issues:
129129

130130
1. The workflow now explicitly updates Cargo to the latest stable version
131131
2. We've added a specific step that runs `rustup update stable` and `rustup default stable`
132-
3. This ensures compatibility with Cargo.lock version 4 format
132+
3. Cargo version is explicitly checked and logged for troubleshooting
133+
4. The workflow automatically regenerates the Cargo.lock file to ensure it uses a format compatible with the current Cargo version
134+
5. This ensures compatibility with Cargo.lock version 4 format (used in newer Rust versions)
135+
6. Any existing Cargo.lock is deleted and freshly regenerated to avoid format conflicts
133136

134137
#### Build Command Not Found
135138

.github/workflows/build.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,23 @@ jobs:
3131
run: |
3232
rustup update stable
3333
rustup default stable
34+
# Check Cargo version explicitly
3435
cargo --version
36+
echo "Using Cargo from: $(which cargo)"
37+
# Ensure we can handle Cargo.lock version 4
38+
echo "Cargo can handle lock version: $(cargo --version | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')"
39+
40+
- name: Regenerate Cargo.lock
41+
run: |
42+
# Remove any existing Cargo.lock
43+
if [ -f Cargo.lock ]; then
44+
echo "Removing existing Cargo.lock"
45+
rm Cargo.lock
46+
fi
47+
# Regenerate Cargo.lock with the latest Cargo version
48+
echo "Regenerating Cargo.lock"
49+
cargo generate-lockfile
50+
echo "Cargo.lock regenerated successfully"
3551
3652
- name: Install Solana CLI
3753
run: |

.github/workflows/tornado_testnet_transaction.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,23 @@ jobs:
7272
run: |
7373
rustup update stable
7474
rustup default stable
75+
# Check Cargo version explicitly
7576
cargo --version
77+
echo "Using Cargo from: $(which cargo)"
78+
# Ensure we can handle Cargo.lock version 4
79+
echo "Cargo can handle lock version: $(cargo --version | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')"
80+
81+
- name: Regenerate Cargo.lock
82+
run: |
83+
# Remove any existing Cargo.lock
84+
if [ -f Cargo.lock ]; then
85+
echo "Removing existing Cargo.lock"
86+
rm Cargo.lock
87+
fi
88+
# Regenerate Cargo.lock with the latest Cargo version
89+
echo "Regenerating Cargo.lock"
90+
cargo generate-lockfile
91+
echo "Cargo.lock regenerated successfully"
7692
7793
- name: Setup metrics directory
7894
run: |

docs/github_actions.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,23 @@ If your workflow fails with errors about Cargo.lock version compatibility:
158158
rustup default stable
159159
```
160160

161-
2. **Version verification:** The workflow now verifies the Cargo version before proceeding with builds
161+
2. **Version verification:** The workflow now verifies the Cargo version before proceeding with builds:
162+
```bash
163+
cargo --version
164+
echo "Using Cargo from: $(which cargo)"
165+
```
166+
167+
3. **Automatic regeneration:** The workflow automatically regenerates the Cargo.lock file with the correct format:
168+
```bash
169+
# Remove any existing Cargo.lock
170+
if [ -f Cargo.lock ]; then
171+
rm Cargo.lock
172+
fi
173+
# Regenerate with latest Cargo version
174+
cargo generate-lockfile
175+
```
162176

163-
3. **Compatibility:** These steps ensure compatibility with Cargo.lock version 4 format
177+
4. **Compatibility:** These steps ensure compatibility with Cargo.lock version 4 format (used in newer Rust versions)
164178

165179
#### Solana Build Command Not Found
166180

0 commit comments

Comments
 (0)