cargo add does not work

Created on 8 Jul 2020  路  8Comments  路  Source: rust-lang/cargo

Problem

$ cargo add
error: no such subcommand: `add`

    Did you mean `doc`?

Output of cargo version: cargo 1.46.0-nightly (c26576f9a 2020-06-23)


C-bug

All 8 comments

cargo add is a third party subcommand; it is not built in to cargo: https://crates.io/crates/cargo-edit

then what's the official command to add dependency? I didn't find similar command from cargo --help

There is not an official command to add a dependency. You can just edit Cargo.toml yourself.

So I need to install a third party package while there is an official package manager? I don't understand and I am confused. I noticed cargo's description is indeed a rust package manager. Isn't dependency management the essential function of a package manager? What is the orientation of cargo?

No, you do not need to install a third party package. You can open Cargo.toml in your text editor of choice and edit the text in it.

Cargo is the Rust package manager. Cargo downloads your Rust package鈥檚 dependencies, compiles your packages, makes distributable packages, and uploads them to crates.io, the Rust community鈥檚 package registry.

Still cargo is not a complete package manager. We can manage memory manually in C/C++, why we use GC in Java/Go, why we use lifecycle and owership in rust? Since there is already an official package manager, one needn't to manage dependencies by editing file manaually, one even needn't to know the format of file. Editing file is only an option. And I advise dependency management should be added to cargo officially.

I advise dependency management should be added to cargo officially.

That would be https://github.com/rust-lang/cargo/issues/5586. We did except it pending there being a comment preserving toml library robust enough to handle all of cargos toml needs. The links from that thread are where to start if you want to push things forward.

Thanks for the report! This appears to be a duplicate of #5586, so closing in favor of that.

Was this page helpful?
0 / 5 - 0 ratings