diff --git a/src/cargo/ops/cargo_install.rs b/src/cargo/ops/cargo_install.rs index 5587625e465..052ac7deb90 100644 --- a/src/cargo/ops/cargo_install.rs +++ b/src/cargo/ops/cargo_install.rs @@ -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)?, diff --git a/tests/testsuite/install.rs b/tests/testsuite/install.rs index 3ed59c9ddfe..b6f046da664 100644 --- a/tests/testsuite/install.rs +++ b/tests/testsuite/install.rs @@ -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");