Skip to content

Commit 3bc5260

Browse files
committed
Auto merge of #5925 - dwijnand:improve-install-cwd-deprecation, r=alexcrichton
Improve the `cargo install` deprecation messaging Fixes #5917 r? @matklad /cc @brson also as I'd love to hear your feedback too.
2 parents c0ec76f + 3e6de57 commit 3bc5260

File tree

3 files changed

+19
-17
lines changed

3 files changed

+19
-17
lines changed

src/bin/cargo/commands/install.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,10 @@ By default cargo will refuse to overwrite existing binaries. The `--force` flag
6060
enables overwriting existing binaries. Thus you can reinstall a crate with
6161
`cargo install --force <crate>`.
6262
63-
As a special convenience, omitting the <crate> specification entirely will
63+
Omitting the <crate> specification entirely will
6464
install the crate in the current directory. That is, `install` is equivalent to
65-
the more explicit `install --path .`.
65+
the more explicit `install --path .`. This behaviour is deprecated, and no
66+
longer supported as of the Rust 2018 edition.
6667
6768
If the source is crates.io or `--git` then by default the crate will be built
6869
in a temporary target directory. To avoid this, the target directory can be

src/cargo/ops/cargo_install.rs

+8-7
Original file line numberDiff line numberDiff line change
@@ -237,15 +237,16 @@ fn install_one(
237237
if from_cwd {
238238
match pkg.manifest().edition() {
239239
Edition::Edition2015 => config.shell().warn(
240-
"To build the current package use `cargo build`, \
241-
to install the current package run `cargo install --path .`",
240+
"Using `cargo install` to install the binaries for the \
241+
project in current working directory is deprecated, \
242+
use `cargo install --path .` instead. \
243+
Use `cargo build` if you want to simply build the package.",
242244
)?,
243245
Edition::Edition2018 => bail!(
244-
"To build the current package use `cargo build`, \
245-
to install the current package run `cargo install --path .`, \
246-
otherwise specify a crate to install from \
247-
crates.io, or use --path or --git to \
248-
specify alternate source"
246+
"Using `cargo install` to install the binaries for the \
247+
project in current working directory is no longer supported, \
248+
use `cargo install --path .` instead. \
249+
Use `cargo build` if you want to simply build the package."
249250
),
250251
}
251252
};

tests/testsuite/install.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -785,9 +785,10 @@ fn installs_from_cwd_by_default() {
785785
assert_that(
786786
cargo_process("install").cwd(p.root()),
787787
execs().with_stderr_contains(
788-
"\
789-
warning: To build the current package use `cargo build`, to install the current package run `cargo install --path .`
790-
",
788+
"warning: Using `cargo install` to install the binaries for the \
789+
project in current working directory is deprecated, \
790+
use `cargo install --path .` instead. \
791+
Use `cargo build` if you want to simply build the package.",
791792
),
792793
);
793794
assert_that(cargo_home(), has_installed_exe("foo"));
@@ -819,11 +820,10 @@ fn installs_from_cwd_with_2018_warnings() {
819820
assert_that(
820821
cargo_process("install").cwd(p.root()).masquerade_as_nightly_cargo(),
821822
execs().with_status(101).with_stderr_contains(
822-
"error: To build the current package use `cargo build`, \
823-
to install the current package run `cargo install --path .`, \
824-
otherwise specify a crate to install from crates.io, \
825-
or use --path or --git to specify alternate source\
826-
",
823+
"error: Using `cargo install` to install the binaries for the \
824+
project in current working directory is no longer supported, \
825+
use `cargo install --path .` instead. \
826+
Use `cargo build` if you want to simply build the package.",
827827
),
828828
);
829829
assert_that(cargo_home(), is_not(has_installed_exe("foo")));

0 commit comments

Comments
 (0)