Auto merge of #11410 - TrAyZeN:master, r=epage

Suggest cargo add when installing library crate

### What does this PR try to resolve?

When using `cargo install` instead of `cargo use` the error message is the following:
```
error: there is nothing to install in `foo v0.0.1`, because it has no binaries
`cargo install` is only for installing programs, and can't be used with libraries.
To use a library crate, add it as a dependency in a Cargo project instead.
```
It would be good to suggest to the user to use `cargo add`.

### How should we test and review this PR?

The `no_binaries` test from `tests/testsuite/install.rs` covers that case.
This commit is contained in:
bors 2023-02-23 18:44:31 +00:00
commit 0625b29d84
2 changed files with 3 additions and 3 deletions

View file

@ -217,8 +217,8 @@ impl<'cfg, 'a> InstallablePackage<'cfg, 'a> {
bail!(
"there is nothing to install in `{}`, because it has no binaries\n\
`cargo install` is only for installing programs, and can't be used with libraries.\n\
To use a library crate, add it as a dependency in a Cargo project instead.",
pkg
To use a library crate, add it as a dependency to a Cargo project with `cargo add`.",
pkg,
);
}

View file

@ -728,7 +728,7 @@ fn no_binaries() {
"\
[ERROR] there is nothing to install in `foo v0.0.1 ([..])`, because it has no binaries[..]
[..]
[..]",
To use a library crate, add it as a dependency to a Cargo project with `cargo add`.",
)
.run();
}