Why cargo build acts different when directly use a package from GitHub or import through other package?

⚓ Rust    📅 2025-04-28    👤 surdeus    👁️ 5      

surdeus

Warning

This post was published 115 days ago. The information described in this article may have changed.

Recently, I've been working with verus-analyzer — a tool similar to rust-analyzer, but designed for parsing Verus code. As part of this work, I imported the ide-assists package from the project.

However, I immediately encountered a compilation error when running:

cargo build
    Updating git repository `https://github.com/verus-lang/verusfmt.git`
error: failed to get `verusfmt` as a dependency of package `ide-assists v0.0.0 (/Users/marsmac/dev/ruzykaller/PromeX-Verus/verus-analyzer/crates/ide-assists)`
    ... which satisfies path dependency `ide-assists` (locked to 0.0.0) of package `ide v0.0.0 (/Users/marsmac/dev/ruzykaller/PromeX-Verus/verus-analyzer/crates/ide)`
    ... which satisfies path dependency `ide` (locked to 0.0.0) of package `PromeX-Verus v0.1.0 (/Users/marsmac/dev/ruzykaller/PromeX-Verus)`

Caused by:
  failed to load source for dependency `verusfmt`

Caused by:
  Unable to update https://github.com/verus-lang/verusfmt.git?branch=optional-updater

Caused by:
  failed to find branch `optional-updater`

Caused by:
  cannot locate remote-tracking branch 'origin/optional-updater'; class=Reference (4); code=NotFound (-3)

The problem stems from a dependency in Cargo.toml, which references a non-existent branch:

verusfmt = { git = "https://github.com/verus-lang/verusfmt.git", branch = "optional-updater", default-features = false }

However, when I build the package directly, it compiles successfully. According to the build log, it pulls the latest commit from the main branch of verusfmt:

Compiling verusfmt v0.5.0 (https://github.com/verus-lang/verusfmt.git?branch=optional-updater#9ea9c5a5)

I'm wondering why this difference happens.

3 posts - 2 participants

Read full topic

🏷️ rust_feed