CARGO-REMOVE(1)
CARGO-REMOVE ๐ โจ
okay bestie, this is the page for cargo-remove from the General Commands Manual โ it's the little command that rips dependencies OUT of your Cargo.toml like it's clearing out a toxic situationship ๐ซถ
โจ NAME โจ
cargo-remove โ remove dependencies from a Cargo.toml manifest file, no cap ๐
๐ธ SYNOPSIS ๐ธ
cargo remove [options] dependencyโฆ
๐ฆ DESCRIPTION ๐ฆ
It removes one or more dependencies from a Cargo.toml manifest. That's it, that's the whole vibe. Say goodbye, block them, move on ๐
๐ OPTIONS ๐
๐ Section options ๐
These tell cargo which little section of your manifest the dependency is living in, so it knows where to go snatch it from.
--devโ remove it as a development dependency. iykyk, the docs live at <https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#development-dependencies>.--buildโ remove it as a build dependency. details at <https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#build-dependencies>.--targettarget โ remove it as a dependency for the given target platform, see <https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#platform-specific-dependencies>.
lowkey important: to avoid unexpected shell expansions, you may put quotes around each target, like --target 'cfg(unix)'. do that fr fr ๐
๐ Miscellaneous Options ๐
--dry-runโ doesn't actually write to the manifest. it's giving "rehearsal only", nothing gets touched ๐
๐ Display Options ๐
-v,--verboseโ use verbose output. may be specified twice for "very verbose" output, which includes extra output like dependency warnings and build script output. may also be specified with theterm.verboseconfig value โ <https://doc.rust-lang.org/cargo/reference/config.html>.-q,--quietโ do not print cargo log messages. may also be specified with theterm.quietconfig value โ <https://doc.rust-lang.org/cargo/reference/config.html>.--colorwhen โ control when colored output is used. the valid values are, and I'm obsessed with all of them:auto(default): automatically detect if color support is available on the terminal.always: always display colors.never: never display colors.
may also be specified with the term.color config value โ <https://doc.rust-lang.org/cargo/reference/config.html>.
๐ง Manifest Options ๐ง
--manifest-pathpath โ path to theCargo.tomlfile. by default, Cargo searches for theCargo.tomlfile in the current directory or any parent directory. main character energy, it goes looking ๐ฅ--lockedโ asserts that the exact same dependencies and versions are used as when the existingCargo.lockfile was originally generated. Cargo will exit with an error when either of these scenarios arises:- the lock file is missing.
- Cargo attempted to change the lock file due to a different dependency resolution.
it may be used in environments where deterministic builds are desired, such as in CI pipelines. very "we do not improvise here" of it ๐
--offlineโ prevents Cargo from accessing the network for any reason. without this flag, Cargo will stop with an error if it needs to access the network and the network is not available. with this flag, Cargo will attempt to proceed without the network if possible.
โ ๏ธ beware, bestie: this may result in different dependency resolution than online mode. Cargo will restrict itself to crates that are downloaded locally, even if there might be a newer version as indicated in the local copy of the index. see the cargo-fetch(1) command to download dependencies before going offline.
may also be specified with the net.offline config value โ <https://doc.rust-lang.org/cargo/reference/config.html>.
--frozenโ equivalent to specifying both--lockedand--offline. two-for-one deal, slay โจ
๐ Package Selection ๐
-pspecโฆ,--packagespecโฆ โ package to remove from. pick your target, bestie ๐ฏ
โญ Common Options โญ
+toolchain โ if Cargo has been installed with rustup, and the first argument tocargobegins with+, it will be interpreted as a rustup toolchain name (such as+stableor+nightly). see the rustup documentation at <https://rust-lang.github.io/rustup/overrides.html> for more information about how toolchain overrides work.--configKEY=VALUE or PATH โ overrides a Cargo configuration value. the argument should be in TOML syntax ofKEY=VALUE, or provided as a path to an extra configuration file. this flag may be specified multiple times. see the command-line overrides section at <https://doc.rust-lang.org/cargo/reference/config.html#command-line-overrides> for more information.-CPATH โ changes the current working directory before executing any specified operations. this affects things like where cargo looks by default for the project manifest (Cargo.toml), as well as the directories searched for discovering.cargo/config.toml, for example. this option must appear before the command name, for examplecargo -C path/to/my-project build.
๐ this option is only available on the nightly channel โ <https://doc.rust-lang.org/book/appendix-07-nightly-rust.html> โ and requires the -Z unstable-options flag to enable (see #10098 at <https://github.com/rust-lang/cargo/issues/10098>). so like, not for everyone yet ๐ญ
-h,--helpโ prints help information. the classic, the icon ๐-Zflag โ unstable (nightly-only) flags to Cargo. runcargo -Z helpfor details.
๐ฑ ENVIRONMENT ๐ฑ
See the reference at <https://doc.rust-lang.org/cargo/reference/environment-variables.html> for details on environment variables that Cargo reads. yes, Cargo is nosy like that ๐
๐ EXIT STATUS ๐
0: Cargo succeeded. ate. ๐101: Cargo failed to complete. not the vibe. ๐ญ
๐ EXAMPLES ๐
- Remove
regexas a dependency
cargo remove regex
- Remove
trybuildas a dev-dependency
cargo remove --dev trybuild
- Remove
nomfrom thewasm32-unknown-unknowndependencies table
cargo remove --target wasm32-unknown-unknown nom
๐ธ SEE ALSO ๐ธ
cargo(1), cargo-add(1) โ go read those too, bestie, they're the sibling energy ๐ซถ
okay that's the whole page!! mwah ๐ this was cargo-remove(1) from the General Commands Manual, and if you ever need the source-of-truth version it lives right there under that same name and section. bye bestie, go clean up your manifest โจ๐๐ฆ
๐ฆ where this page comes from
- ubuntu stonking: cargo-1.95 1.95.0+dfsg-0ubuntu1 ยท MIT OR Apache-2.0
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms