Need help with cargo-edit?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

killercup
1.7K Stars 102 Forks MIT License 679 Commits 64 Opened issues

Description

A utility for managing cargo dependencies from the command line.

Services available

!
?

Need anything else?

Contributors list

# 31,901
Rust
rust-la...
React
React N...
153 commits
# 50,335
Rust
swagger
rest-cl...
openapi
69 commits
# 72,309
Rust
Shell
rust-la...
cargo
66 commits
# 214,547
Rust
jieba
Telegra...
C
41 commits
# 88,270
OCaml
opam
TeX
lambda-...
19 commits
# 270,489
Rust
Shell
CSS
cargo
16 commits
# 294,345
github-...
GitHub ...
GitHub
Rust
15 commits
# 350,221
Rust
cargo
Shell
11 commits
# 6,629
eclipse
CSS
Rust
gitigno...
7 commits
# 392,500
Shell
Rust
Docker
cargo
6 commits
# 63,499
Rust
Node.js
node
Package...
6 commits
# 236,917
Rust
Shell
HTML
load-te...
6 commits
# 363,100
Rust
crypto-...
steam
Shell
5 commits
# 75,742
Rust
Shell
C
React
5 commits
# 433,382
cargo
Rust
5 commits
# 50,228
Rust
Linux
rfc
C
4 commits
# 189,544
Rust
travis-...
webfram...
webrtc
4 commits
# 346,153
Shell
Nim
HTML
mustach...
4 commits
# 33,797
Rust
Django
openvpn
argumen...
3 commits
# 11,190
github-...
Electro...
phantom...
clang-f...
3 commits

cargo edit

This tool extends Cargo to allow you to add, remove, and upgrade dependencies by modifying your

Cargo.toml
file from the command line.

Currently available subcommands:

Build Status Build Status Build status Coverage Status crates.io Join the chat at https://gitter.im/cargo-edit/Lobby

Contribution

Thanks for your interest - we gratefully welcome contributions.

Questions can be asked in issues, or on Gitter.

To help us help you get pull requests merged quickly and smoothly, open an issue before submitted large changes. Please keep the contents of pull requests and commits short. Commit messages should include the intent of the commit.

cargo-edit
has a moderately comprehensive test suite. Contributions that add/improve tests are awesome. Please add tests for every change.

cargo-edit
uses
rustfmt
for formatting and
clippy
for linting.

Installation

Ensure that you have a fairly recent version of rust/cargo installed. On Ubuntu you would also need to install

libssl-dev
and
pkg-config
packages.
$ cargo install cargo-edit

If you wish to use a bundled version of

openssl
:
$ cargo install cargo-edit --features vendored-openssl

Compiler support: requires rustc 1.44+

(Please check

cargo
's documentation to learn how

cargo install
works and how to set up your system so it finds binaries installed by
cargo
.)

Install a sub-set of the commands with

cargo install -f --no-default-features --features ""
, where
 is a space-separated list of commands; i.e. 
add rm upgrade
for the full set.

Available Subcommands

cargo add

Add new dependencies to your

Cargo.toml
. When no version is specified,
cargo add
will try to query the latest version's number from crates.io.

Examples

$ # Add a specific version
$ cargo add [email protected] --dev
$ # Query the latest version from crates.io and adds it as build dependency
$ cargo add gcc --build
$ # Add a non-crates.io crate
$ cargo add local_experiment --path=lib/trial-and-error/
$ # Add a non-crates.io crate; the crate name will be found automatically
$ cargo add lib/trial-and-error/
$ # Add a crates.io crate with a local development path
$ cargo add my_helper --vers=1.3.1 --path=lib/my-helper/
$ # Add a renamed dependency
$ cargo add thiserror --rename error

Usage

$ cargo add -h
cargo-add
Add dependency to a Cargo.toml manifest file

USAGE: cargo add [FLAGS] [OPTIONS] ...

FLAGS: --allow-prerelease Include prerelease versions when fetching from crates.io (e.g. '0.6.0-alpha') -B, --build Add crate as build dependency -D, --dev Add crate as development dependency -h, --help Prints help information --no-default-features Set default-features = false for the added dependency --offline Run without accessing the network --optional Add as an optional dependency (for use in features) -q, --quiet Do not print any output in case of success -s, --sort Sort dependencies even if currently unsorted -V, --version Prints version information

OPTIONS: --branch Specify a git branch to download the crate from --features ... Space-separated list of features to add. For an alternative approach to enabling features, consider installing the cargo-feature utility --git Specify a git repository to download the crate from --manifest-path Path to the manifest to add a dependency to --path Specify the path the crate should be loaded from -p, --package Package id of the crate to add this dependency to --registry Registry to use -r, --rename Rename a dependency in Cargo.toml, https://doc.rust- lang.org/cargo/reference/specifying- dependencies.html#renaming-dependencies-in-cargotoml Only works when specifying a single dependency --target Add as dependency to the given target platform --upgrade Choose method of semantic version upgrade. Must be one of "none" (exact version, = modifier), "patch" (~ modifier), "minor" (^ modifier), "all" (>=), or "default" (no modifier) [default: default] [possible values: none, patch, minor, all, default] --vers Specify the version to grab from the registry(crates.io). You can also specify version as part of name, e.g cargo add [email protected]

ARGS: ... Crates to be added

This command allows you to add a dependency to a Cargo.toml manifest file. If is a github or gitlab repository URL, or a local path, cargo add will try to automatically get the crate name and set the appropriate --git or --path value.

Please note that Cargo treats versions like '1.2.3' as '^1.2.3' (and that '^1.2.3' is specified as '>=1.2.3 and <2.0.0'). By default, cargo add will use this format, as it is the one that the crates.io registry suggests. One goal of cargo add is to prevent you from using wildcard dependencies (version set to '*').

cargo rm

Remove dependencies from your

Cargo.toml
.

Examples

$ # Remove a dependency
$ cargo rm regex
$ # Remove a development dependency
$ cargo rm regex --dev
$ # Remove a build dependency
$ cargo rm regex --build

Usage

$ cargo rm -h
cargo-rm
Remove a dependency from a Cargo.toml manifest file

USAGE: cargo rm [FLAGS] [OPTIONS] ...

FLAGS: -B, --build Remove crate as build dependency -D, --dev Remove crate as development dependency -h, --help Prints help information -q, --quiet Do not print any output in case of success -V, --version Prints version information

OPTIONS: --manifest-path Path to the manifest to remove a dependency from -p, --package Specify the package in the workspace to add a dependency to (see cargo help pkgid)

ARGS: ... Crates to be removed

cargo upgrade

Upgrade dependencies in your

Cargo.toml
to their latest versions.

To specify a version to upgrade to, provide the dependencies in the

@
format, e.g.
cargo upgrade [email protected]~0.9.0 [email protected]>=0.9,<2.0
.

This command differs from

cargo update
, which updates the dependency versions recorded in the local lock file (Cargo.lock).

Examples

# Upgrade all dependencies for the current crate
$ cargo upgrade
# Upgrade docopt (to ~0.9) and serde (to >=0.9,<2.0)
$ cargo upgrade [email protected]~0.9 [email protected]>=0.9,<2.0
# Upgrade regex (to the latest version) across all crates in the workspace
$ cargo upgrade regex --workspace
# Upgrade all dependencies except docopt and serde
$ cargo upgrade --exclude docopt serde

Usage

$ cargo upgrade -h
cargo-upgrade
Upgrade dependencies as specified in the local manifest file (i.e. Cargo.toml)

USAGE: cargo upgrade [FLAGS] [OPTIONS] [dependency]...

FLAGS: --workspace Upgrade all packages in the workspace --allow-prerelease Include prerelease versions when fetching from crates.io (e.g. 0.6.0-alpha') --dry-run Print changes to be made without making them -h, --help Prints help information --offline Run without accessing the network --skip-compatible Only update a dependency if the new version is semver incompatible --to-lockfile Upgrade all packages to the version in the lockfile -V, --version Prints version information

OPTIONS: --exclude ... Crates to exclude and not upgrade --manifest-path Path to the manifest to upgrade -p, --package Specify the package in the workspace to add a dependency to (see cargo help pkgid)

ARGS: ... Crates to be upgraded

This command differs from cargo update, which updates the dependency versions recorded in the local lock file (Cargo.lock).

If <dependency>(s) are provided, only the specified dependencies will be upgraded. The version to upgrade to for each can be specified with e.g. [email protected] or [email protected]&gt;=0.9,&lt;2.0.

Dev, build, and all target dependencies will also be upgraded. Only dependencies from crates.io are supported. Git/path dependencies will be ignored.

All packages in the workspace will be upgraded if the --workspace flag is supplied. The --workspace flag may be supplied in the presence of a virtual manifest.

If the '--to-lockfile' flag is supplied, all dependencies will be upgraded to the currently locked version as recorded in the Cargo.lock file. This flag requires that the Cargo.lock file is up-to-date. If the lock file is missing, or it needs to be updated, cargo-upgrade will exit with an error. If the '--to-lockfile' flag is supplied then the network won't be accessed.

License

Apache-2.0/MIT

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.