Skip to content

Unable to cargo update git dependency with two branches used at the same time #8481

@Riateche

Description

@Riateche

Problem

cargo update -p package doesn't work and produces a non-working suggestion.

Steps

Workspace archive attached for convenience: w1.zip

  1. Create a workspace with two libraries, lib1 and lib2.
  2. Add a dependency to lib1: rand = { git = "https://github.com/rust-random/rand.git" }
  3. Add a dependency to lib2: rand = { git = "https://github.com/rust-random/rand.git", branch = "0.7" }
  4. Run cargo check or anything that generates a lock file.
  5. Run cargo update -p rand. Output:
error: There are multiple `rand` packages in your project, and the specification `rand` is ambiguous.
Please re-run this command with `-p <spec>` where `<spec>` is one of the following:
  https://github.com/rust-random/rand.git#rand:0.7.4
  https://github.com/rust-random/rand.git#rand:0.7.4
  1. Run cargo update -p 'https://github.com/rust-random/rand.git#rand:0.7.4'
error: There are multiple `rand` packages in your project, and the specification `https://github.com/rust-random/rand.git#rand:0.7.4` is ambiguous.
Please re-run this command with `-p <spec>` where `<spec>` is one of the following:
  https://github.com/rust-random/rand.git#rand:0.7.4
  https://github.com/rust-random/rand.git#rand:0.7.4

There should be a way to disambiguate between these packages.

Notes

Output of cargo version:
cargo 1.44.1 (88ba85757 2020-06-11)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions