Skip to content

cargo add multiple packages found at no suggestion #11173

@pickfire

Description

@pickfire

Problem

I ran cargo add to try out a git dependency

> cargo add --git https://github.com/tokio-rs/axum
    Updating git repository `https://github.com/tokio-rs/axum`
error: multiple packages found at `https://github.com/tokio-rs/axum`: axum, axum-core, axum-extra, axum-macros, example-anyhow-error-response, example-chat, example-consume-body-in-extractor-or-middleware, example-cors, example-customize-extractor-error, example-customize-path-rejection, example-error-handling-and-dependency-injection, example-form, example-global-404-handler, example-graceful-shutdown, example-handle-head-request, example-hello-world, example-http-proxy, example-jwt, example-key-value-store, example-low-level-rustls, example-multipart-form, example-oauth, example-parse-body-based-on-content-type, example-print-request-response, example-prometheus-metrics, example-query-params-with-empty-strings, example-readme, example-rest-grpc-multiplex, example-reverse-proxy, example-routes-and-handlers-close-together, example-sessions, example-simple-router-wasm, example-sqlx-postgres, example-sse, example-static-file-server, example-stream-to-file, example-templates, example-testing, example-tls-rustls, example-todos, example-tokio-postgres, example-tracing-aka-logging, example-unix-domain-socket, example-validator, example-versioning, example-websockets, listen-multiple-addrs

I have tried many ways due to missing suggestion to get it work like what I wanted.

Steps

  1. I have no idea what do I do next.
  2. I tried cargo add --git https://github.com/tokio-rs/axum -p axum but it also didn't work as I expected.
  3. I tried cargo add --git https://github.com/tokio-rs/axum axum but I didn't know it worked as I expected when I cancelled it.
  4. I tried cargo add --git https://github.com/tokio-rs/axum --path axum but it also didn't work as I expected.
  5. I tried cargo add --git https://github.com/tokio-rs/axum/axum but it also didn't work as I expected.
  6. I looked at help with cargo add -h but I didn't find what I wanted.
  7. I looked at cargo help add but I didn't find what I wanted.
  8. I search github issues... didn't really find anything useful.
  9. I tried cargo add --git https://github.com/tokio-rs/axum axum but this time I didn't cancelled it.
  10. I check the Cargo.toml and it is what I wanted.

Possible Solution(s)

  • the error should be more descriptive, it should suggest what do I do next (add a space + crate), not just show me the list of packages
  • the help page cargo add [options] --git url [crate...] is not clear that [crate...] refers to the git url, in the --git part it should specifically mention that the [crate...] mentioned is different from cargo add [options] crate....

Notes

No response

Version

cargo 1.64.0 (387270bc7 2022-09-16)
release: 1.64.0
commit-hash: 387270bc7f446d17869c7f208207c73231d6a252
commit-date: 2022-09-16
host: x86_64-unknown-linux-gnu
libgit2: 1.4.2 (sys:0.14.2 vendored)
libcurl: 7.83.1-DEV (sys:0.4.55+curl-7.83.1 vendored ssl:OpenSSL/1.1.1q)
os: Arch Linux Rolling Release [64-bit]

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