cargo-lock-manager

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Quick Usage (Already Configured)

快速使用(已配置完成)

Check Cargo.lock status

检查Cargo.lock状态

bash
cd packages/desktop/src-tauri
cargo check --locked 2>&1 | head -20
bash
cd packages/desktop/src-tauri
cargo check --locked 2>&1 | head -20

Update Cargo.lock locally

本地更新Cargo.lock

bash
cd packages/desktop/src-tauri
cargo update --workspace
bash
cd packages/desktop/src-tauri
cargo update --workspace

Test with --locked after update

更新后使用--locked进行测试

bash
cd packages/desktop/src-tauri
cargo test --locked
bash
cd packages/desktop/src-tauri
cargo test --locked

Common Gotchas

常见注意事项

  • The
    --locked
    flag prevents automatic updates to Cargo.lock, which is good for reproducible builds but fails when dependencies change.
  • PRs often fail because the lock file wasn't committed after dependency updates.
  • Running
    cargo update
    without
    --workspace
    may not update all workspace members.
  • --locked
    标记会阻止Cargo.lock自动更新,这有助于实现可复现构建,但在依赖项变更时会执行失败。
  • 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 push
bash
cd packages/desktop/src-tauri
cargo update --workspace
git add Cargo.lock
git commit -m "chore: update Cargo.lock"
git push

Option 2: Use --offline flag (for air-gapped environments)

选项2:使用--offline标记(适用于离线环境)

bash
cargo test --manifest-path packages/desktop/src-tauri/Cargo.toml --offline
bash
cargo test --manifest-path packages/desktop/src-tauri/Cargo.toml --offline

First-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
    cargo check
    or
    cargo build
    after modifying
    Cargo.toml
    files
  • Include
    Cargo.lock
    changes in the same commit as dependency updates
  • Consider adding a pre-commit hook to verify lock file is up to date
  • 修改
    Cargo.toml
    文件后,务必运行
    cargo check
    cargo build
  • 将Cargo.lock的变更与依赖项更新提交到同一个commit中
  • 考虑添加pre-commit钩子来验证锁文件是否为最新版本