cargo-lock-manager
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseQuick Usage (Already Configured)
快速使用(已配置完成)
Check Cargo.lock status
检查Cargo.lock状态
bash
cd packages/desktop/src-tauri
cargo check --locked 2>&1 | head -20bash
cd packages/desktop/src-tauri
cargo check --locked 2>&1 | head -20Update Cargo.lock locally
本地更新Cargo.lock
bash
cd packages/desktop/src-tauri
cargo update --workspacebash
cd packages/desktop/src-tauri
cargo update --workspaceTest with --locked after update
更新后使用--locked进行测试
bash
cd packages/desktop/src-tauri
cargo test --lockedbash
cd packages/desktop/src-tauri
cargo test --lockedCommon Gotchas
常见注意事项
- The flag prevents automatic updates to Cargo.lock, which is good for reproducible builds but fails when dependencies change.
--locked - PRs often fail because the lock file wasn't committed after dependency updates.
- Running without
cargo updatemay not update all workspace members.--workspace
- 标记会阻止Cargo.lock自动更新,这有助于实现可复现构建,但在依赖项变更时会执行失败。
--locked - PR经常失败是因为依赖项更新后未提交锁文件。
- 在不添加参数的情况下运行
--workspace可能无法更新所有工作区成员。cargo update
When CI Fails with --locked
当CI因--locked失败时
Option 1: Update lock file and commit (Recommended)
选项1:更新锁文件并提交(推荐)
bash
cd packages/desktop/src-tauri
cargo update --workspace
git add Cargo.lock
git commit -m "chore: update Cargo.lock"
git pushbash
cd packages/desktop/src-tauri
cargo update --workspace
git add Cargo.lock
git commit -m "chore: update Cargo.lock"
git pushOption 2: Use --offline flag (for air-gapped environments)
选项2:使用--offline标记(适用于离线环境)
bash
cargo test --manifest-path packages/desktop/src-tauri/Cargo.toml --offlinebash
cargo test --manifest-path packages/desktop/src-tauri/Cargo.toml --offlineFirst-Time Setup (If Not Configured)
首次设置(若未配置)
No setup required. This skill assumes:
- Rust/Cargo is installed
- You're in the openwork repository
- The Tauri app is in
packages/desktop/src-tauri/
无需额外设置。本技能基于以下假设:
- 已安装Rust/Cargo
- 你处于openwork代码仓库中
- Tauri应用位于路径下
packages/desktop/src-tauri/
Prevention Tips
预防建议
- Always run or
cargo checkafter modifyingcargo buildfilesCargo.toml - Include changes in the same commit as dependency updates
Cargo.lock - Consider adding a pre-commit hook to verify lock file is up to date
- 修改文件后,务必运行
Cargo.toml或cargo checkcargo build - 将Cargo.lock的变更与依赖项更新提交到同一个commit中
- 考虑添加pre-commit钩子来验证锁文件是否为最新版本