How do I uninstall a crate?

Having put a horrid crate in Cargo.toml I want to get rid of it.

In my Cargo.toml file I have

[dependencies]
horridcrate = "6.6.6"

(I do not want to say what crate as I may be slandering it, and this is a geeneral query)

Can I just delete the directory
.cargo/registry/src/github.com-[hexidecimal-stuff]/horridcrate ?

1 Like

Stuff in .cargo/registry/src is just the plain source code, not really "installed". It will also be in .cargo/registry/cache as its original packed horridcrate-6.6.6.crate file. You can feel free to delete these, and it will only be re-downloaded if you use it in a project again.

Programs you installed with cargo install go in .cargo/bin, and you can use cargo uninstall for them if desired. To see what you have, run cargo install --list.

3 Likes

Yeap; and there's an open issue (cargo#3289) for a command to clear the cache.

There's also a third party cargo subcommand — cargo-cache — that removes entire cargo cache directories (but not individual horridcates). It's been updated recently (4 days ago), but it's not published on crates.io.

2 Likes

Removing it from Cargo.toml and running build again is of course enough to "uninstall" it for the current project. You don't need to delete any files unless the crate offended you so hard you can't stand having it in the cache, doing nothing.

5 Likes