On a repository's releases page, every crate's card shows cargo add <crate>@<version> --registry <name>, including a crate that is only a program. On https://knotless.dev/chadtmiller.com/cargo-test/releases, hello (a src/main.rs and no library) shows cargo add hello@0.1.0 --registry cargo-test. Running that adds a dependency that can't be used. What works is cargo install hello --registry cargo-test.
How to see it
Publish a crate that has only a binary target to a repository's Cargo registry with cargo publish --registry <name>.
Open the repository's releases page. The card offers cargo add.
What you expected
A crate with binaries and no library shows cargo install <crate> --registry <name>. A crate with both could show both commands. The registry would have to work this out at publish time. Neither the index line nor the release's cargo field records a crate's targets now. It could check the .crate for src/main.rs, src/bin/ or [[bin]], and for src/lib.rs or [lib], the same way it reads Cargo.toml already. It would record the result in the release, and listReleases would return it next to crate.
What happened
On a repository's releases page, every crate's card shows
cargo add <crate>@<version> --registry <name>, including a crate that is only a program. On https://knotless.dev/chadtmiller.com/cargo-test/releases,hello(asrc/main.rsand no library) showscargo add hello@0.1.0 --registry cargo-test. Running that adds a dependency that can't be used. What works iscargo install hello --registry cargo-test.How to see it
cargo publish --registry <name>.cargo add.What you expected
A crate with binaries and no library shows
cargo install <crate> --registry <name>. A crate with both could show both commands. The registry would have to work this out at publish time. Neither the index line nor the release'scargofield records a crate's targets now. It could check the.crateforsrc/main.rs,src/bin/or[[bin]], and forsrc/lib.rsor[lib], the same way it readsCargo.tomlalready. It would record the result in the release, andlistReleaseswould return it next tocrate.Where
knotless.dev, the releases page.