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.

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 the term.verbose config value โ€” <https://doc.rust-lang.org/cargo/reference/config.html>.
  • -q, --quiet โ€” do not print cargo log messages. may also be specified with the term.quiet config value โ€” <https://doc.rust-lang.org/cargo/reference/config.html>.
  • --color when โ€” 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-path path โ€” path to the Cargo.toml file. by default, Cargo searches for the Cargo.toml file 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 existing Cargo.lock file 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 --locked and --offline. two-for-one deal, slay โœจ

๐Ÿ’œ Package Selection ๐Ÿ’œ

  • -p specโ€ฆ, --package specโ€ฆ โ€” package to remove from. pick your target, bestie ๐ŸŽฏ

โญ Common Options โญ

  • +toolchain โ€” if Cargo has been installed with rustup, and the first argument to cargo begins with +, it will be interpreted as a rustup toolchain name (such as +stable or +nightly). see the rustup documentation at <https://rust-lang.github.io/rustup/overrides.html> for more information about how toolchain overrides work.
  • --config KEY=VALUE or PATH โ€” overrides a Cargo configuration value. the argument should be in TOML syntax of KEY=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.
  • -C PATH โ€” 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 example cargo -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 ๐Ÿ‘‘
  • -Z flag โ€” unstable (nightly-only) flags to Cargo. run cargo -Z help for 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 ๐Ÿ’€

  1. 0: Cargo succeeded. ate. ๐Ÿ’…
  2. 101: Cargo failed to complete. not the vibe. ๐Ÿ˜ญ

๐ŸŽ€ EXAMPLES ๐ŸŽ€

  1. Remove regex as a dependency
cargo remove regex
  1. Remove trybuild as a dev-dependency
cargo remove --dev trybuild
  1. Remove nom from the wasm32-unknown-unknown dependencies 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