Skip to content

Commit 0625b29

Browse files
committed
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.
2 parents c65a4d1 + 98edd70 commit 0625b29

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/cargo/ops/cargo_install.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,8 @@ impl<'cfg, 'a> InstallablePackage<'cfg, 'a> {
217217
bail!(
218218
"there is nothing to install in `{}`, because it has no binaries\n\
219219
`cargo install` is only for installing programs, and can't be used with libraries.\n\
220-
To use a library crate, add it as a dependency in a Cargo project instead.",
221-
pkg
220+
To use a library crate, add it as a dependency to a Cargo project with `cargo add`.",
221+
pkg,
222222
);
223223
}
224224

tests/testsuite/install.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -728,7 +728,7 @@ fn no_binaries() {
728728
"\
729729
[ERROR] there is nothing to install in `foo v0.0.1 ([..])`, because it has no binaries[..]
730730
[..]
731-
[..]",
731+
To use a library crate, add it as a dependency to a Cargo project with `cargo add`.",
732732
)
733733
.run();
734734
}

0 commit comments

Comments
 (0)