Cargo install and cargo add confusion


I am reading and its install counterpart.

In the example of cargo install, ripgrep is taken in example.
As seen in the upper right corner of the page, you can install it via

cargo add ripgrep

and, down in the page, it is written that Rust users install it via

$ cargo install ripgrep

My understanding so far is that cargo install is used when you just create a project and "import" an already existing binary into the project, and cargo add afterwards, but I am completely confused now.

Is cargo add overlapping install?

Sorry for this newbish question


The "installation" instructions in the right-hand pane of are autogenerated for all libraries. It is showing you how to add ripgrep as a library dependency in an existing project.

You likely want to use ripgrep as a cli tool however, so cargo install ripgrep will install that in your ~/.cargo/bin directory

Got it, thanks Ryan