Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve the cargo install deprecation messaging #5925

Merged
merged 2 commits into from
Aug 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/bin/cargo/commands/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,10 @@ By default cargo will refuse to overwrite existing binaries. The `--force` flag
enables overwriting existing binaries. Thus you can reinstall a crate with
`cargo install --force <crate>`.

As a special convenience, omitting the <crate> specification entirely will
Omitting the <crate> specification entirely will
install the crate in the current directory. That is, `install` is equivalent to
the more explicit `install --path .`.
the more explicit `install --path .`. This behaviour is deprecated, and no
longer supported as of the Rust 2018 edition.

If the source is crates.io or `--git` then by default the crate will be built
in a temporary target directory. To avoid this, the target directory can be
Expand Down
15 changes: 8 additions & 7 deletions src/cargo/ops/cargo_install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,15 +237,16 @@ fn install_one(
if from_cwd {
match pkg.manifest().edition() {
Edition::Edition2015 => config.shell().warn(
"To build the current package use `cargo build`, \
to install the current package run `cargo install --path .`",
"Using `cargo install` to install the binaries for the \
project in current working directory is deprecated, \
use `cargo install --path .` instead. \
Use `cargo build` if you want to simply build the package.",
)?,
Edition::Edition2018 => bail!(
"To build the current package use `cargo build`, \
to install the current package run `cargo install --path .`, \
otherwise specify a crate to install from \
crates.io, or use --path or --git to \
specify alternate source"
"Using `cargo install` to install the binaries for the \
project in current working directory is no longer supported, \
use `cargo install --path .` instead. \
Use `cargo build` if you want to simply build the package."
),
}
};
Expand Down
16 changes: 8 additions & 8 deletions tests/testsuite/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -785,9 +785,10 @@ fn installs_from_cwd_by_default() {
assert_that(
cargo_process("install").cwd(p.root()),
execs().with_stderr_contains(
"\
warning: To build the current package use `cargo build`, to install the current package run `cargo install --path .`
",
"warning: Using `cargo install` to install the binaries for the \
project in current working directory is deprecated, \
use `cargo install --path .` instead. \
Use `cargo build` if you want to simply build the package.",
),
);
assert_that(cargo_home(), has_installed_exe("foo"));
Expand Down Expand Up @@ -819,11 +820,10 @@ fn installs_from_cwd_with_2018_warnings() {
assert_that(
cargo_process("install").cwd(p.root()).masquerade_as_nightly_cargo(),
execs().with_status(101).with_stderr_contains(
"error: To build the current package use `cargo build`, \
to install the current package run `cargo install --path .`, \
otherwise specify a crate to install from crates.io, \
or use --path or --git to specify alternate source\
",
"error: Using `cargo install` to install the binaries for the \
project in current working directory is no longer supported, \
use `cargo install --path .` instead. \
Use `cargo build` if you want to simply build the package.",
),
);
assert_that(cargo_home(), is_not(has_installed_exe("foo")));
Expand Down