almel
almel

Reputation: 7938

How do I list all of the packages I've installed globally with cargo install?

I've installed several CLI tools using cargo install (for instance, ripgrep). How do I see a list of all the crates I've downloaded using cargo install? Sort of like apt list --installed but for cargo?

Upvotes: 94

Views: 44191

Answers (4)

Masa Maeda
Masa Maeda

Reputation: 48

A bit late to the party here but I recently needed to install all the packages on one machine on another so I came up with this little sequence

cargo install --list | awk '/^\w/ {print $1}' | tr '\n' ' ' | ssh [yourremote] "xargs cargo install"

If you just need the package names cargo install --list | awk '/^\w/ {print $1}' will get you just the package names.

Upvotes: 0

Ahmad Ismail
Ahmad Ismail

Reputation: 13862

If you want to manipulate the list shown by cargo install --list, then please check:

cat $CARGO_HOME/.crates.toml
cat $CARGO_HOME/.crates2.json | jq .

Please note that .crates2.json is in json format.

To list out the installed package names you could run:

cat $CARGO_HOME/.crates2.json | jq -r '.installs | keys[] | split(" ")[0]'

Upvotes: 1

IInspectable
IInspectable

Reputation: 51413

The command line

cargo help install

produces detailed help information. Among others, it lists common EXAMPLES, e.g.

  1. View the list of installed packages:

    cargo install --list
    

This lists all installed packages alongside their versions and the collection of binaries contained. Doing this is superior to other proposed solutions as packages can contain multiple binaries (e.g. cargo-edit) or have a binary name that doesn't match the crate name (such as ripgrep).

Just be careful not to type cargo install list as that is trying to install the list package, which thankfully errors out at the time of writing (as opposed to installing a rogue binary).

Upvotes: 114

almel
almel

Reputation: 7938

ls ~/.cargo/bin/

The binary files are stored here, so listing all the files in this directory will give you all the global cargo crates you've installed.

Upvotes: 14

Related Questions