Skip to content

Commit f19d066

Browse files
committed
Suggest cargo add when installing library crate
1 parent ba607b2 commit f19d066

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/cargo/ops/cargo_install.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,10 @@ impl<'cfg, 'a> InstallablePackage<'cfg, 'a> {
209209
bail!(
210210
"there is nothing to install in `{}`, because it has no binaries\n\
211211
`cargo install` is only for installing programs, and can't be used with libraries.\n\
212-
To use a library crate, add it as a dependency in a Cargo project instead.",
213-
pkg
212+
To use a library crate, add it as a dependency in a Cargo project instead.\n\
213+
Use `cargo add {}` if you want to simply add it as a dependency of the current Cargo project.",
214+
pkg,
215+
pkg.name()
214216
);
215217
}
216218

tests/testsuite/install.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -730,7 +730,8 @@ fn no_binaries() {
730730
"\
731731
[ERROR] there is nothing to install in `foo v0.0.1 ([..])`, because it has no binaries[..]
732732
[..]
733-
[..]",
733+
[..]
734+
Use `cargo add foo` if you want to simply add it as a dependency of the current Cargo project.",
734735
)
735736
.run();
736737
}

0 commit comments

Comments
 (0)