cargo-add --- Add dependencies to a Cargo.toml manifest file
cargo add
[options] crate...cargo add
[options] --path
pathcargo add
[options] --git
url [crate...]\
This command can add or modify dependencies.
The source for the dependency can be specified with:
@
version: Fetch from a registry with a version constraint of “version”--path
path: Fetch from the specified path--git
url: Pull from a git repo at urlIf no source is specified, then a best effort will be made to select one, including:
dev-dependencies
)When you add a package that is already present, the existing entry will be updated with the flags specified.
Upon successful invocation, the enabled (+
) and disabled (-
) features of the specified dependency will be listed in the command's output.
See the reference for details on environment variables that Cargo reads.
0
: Cargo succeeded.101
: Cargo failed to complete.Add regex
as a dependency
cargo add regex
Add trybuild
as a dev-dependency
cargo add --dev trybuild
Add an older version of nom
as a dependency
cargo add nom@5
Add support for serializing data structures to json with derive
s
cargo add serde serde_json -F serde/derive
Add windows
as a platform specific dependency on cfg(windows)
cargo add windows --target 'cfg(windows)'