Skip to content

In 2018 edition, warn about cargo installing the current crateΒ #5327

@matklad

Description

@matklad

Running cargo install installs the binaries for the project in current working directory. This might be a surprising behavior for people coming from other ecosystems, especially the node one. The confusion here is that, in Cargo, you don't need to "install" a library to actually use it. At the same time, installing local crates seems like a niche use-case, one typically installs crates from crates.io.

So let's fix confusion by printing a warning, in the next edition, when a user invokes cargo install. The warning should say:

  • If you care coming from other ecosystems, you probably have meant cargo build
  • If you really want to install current package, run cargo install --path .

The code for install command is here:

To check the current edition, one can use this method:

pub fn edition(&self) -> Edition {

The tests for install are here:

https://github.com/rust-lang/cargo/blob/d8b20310217e5e2bc515c13111ab9a7789709e42/tests/testsuite/install.rs

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions