Skip to content

Commit

Permalink
Improve error message when running cargo install .
Browse files Browse the repository at this point in the history
  • Loading branch information
twe4ked committed Apr 20, 2020
1 parent 5b620dc commit 0c14dc2
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/cargo/ops/cargo_install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,15 @@ fn install_one(
no_track: bool,
is_first_install: bool,
) -> CargoResult<()> {
if let Some(name) = krate {
if name == "." {
bail!(
"To install the binaries for the package in current working \
directory use `cargo install --path .`. \
Use `cargo build` if you want to simply build the package."
)
}
}
let pkg = if source_id.is_git() {
select_pkg(
GitSource::new(source_id, config)?,
Expand Down
14 changes: 14 additions & 0 deletions tests/testsuite/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,20 @@ fn missing() {
.run();
}

#[cargo_test]
fn missing_current_working_directory() {
cargo_process("install .")
.with_status(101)
.with_stderr(
"\
error: To install the binaries for the package in current working \
directory use `cargo install --path .`. Use `cargo build` if you \
want to simply build the package.
",
)
.run();
}

#[cargo_test]
fn bad_version() {
pkg("foo", "0.0.1");
Expand Down

0 comments on commit 0c14dc2

Please sign in to comment.