]> git.proxmox.com Git - cargo.git/blob - src/doc/man/generated_txt/cargo-add.txt
832f53169e109e922e5d8f52d5e2a7431f333b5a
[cargo.git] / src / doc / man / generated_txt / cargo-add.txt
1 CARGO-ADD(1)
2
3 NAME
4 cargo-add - Add dependencies to a Cargo.toml manifest file
5
6 SYNOPSIS
7 cargo add [options] crate...
8 cargo add [options] --path path
9 cargo add [options] --git url [crate...]
10
11 DESCRIPTION
12 This command can add or modify dependencies.
13
14 The source for the dependency can be specified with:
15
16 o crate@version: Fetch from a registry with a version constraint of
17 "version"
18
19 o --path path: Fetch from the specified path
20
21 o --git url: Pull from a git repo at url
22
23 If no source is specified, then a best effort will be made to select
24 one, including:
25
26 o Existing dependencies in other tables (like dev-dependencies)
27
28 o Workspace members
29
30 o Latest release in the registry
31
32 When you add a package that is already present, the existing entry will
33 be updated with the flags specified.
34
35 Upon successful invocation, the enabled (+) and disabled (-) features
36 <https://doc.rust-lang.org/cargo/reference/features.md> of the specified
37 dependency will be listed in the command's output.
38
39 OPTIONS
40 Source options
41 --git url
42 Git URL to add the specified crate from
43 <https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#specifying-dependencies-from-git-repositories>.
44
45 --branch branch
46 Branch to use when adding from git.
47
48 --tag tag
49 Tag to use when adding from git.
50
51 --rev sha
52 Specific commit to use when adding from git.
53
54 --path path
55 Filesystem path
56 <https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#specifying-path-dependencies>
57 to local crate to add.
58
59 --registry registry
60 Name of the registry to use. Registry names are defined in Cargo
61 config files
62 <https://doc.rust-lang.org/cargo/reference/config.html>. If not
63 specified, the default registry is used, which is defined by the
64 registry.default config key which defaults to crates-io.
65
66 Section options
67 --dev
68 Add as a development dependency
69 <https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#development-dependencies>.
70
71 --build
72 Add as a build dependency
73 <https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#build-dependencies>.
74
75 --target target
76 Add as a dependency to the given target platform
77 <https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#platform-specific-dependencies>.
78
79 </dl>
80
81 Dependency options
82 --rename name
83 Rename
84 <https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#renaming-dependencies-in-cargotoml>
85 the dependency.
86
87 --optional
88 Mark the dependency as optional
89 <https://doc.rust-lang.org/cargo/reference/features.html#optional-dependencies>.
90
91 --no-optional
92 Mark the dependency as required
93 <https://doc.rust-lang.org/cargo/reference/features.html#optional-dependencies>.
94
95 --no-default-features
96 Disable the default features
97 <https://doc.rust-lang.org/cargo/reference/features.html#dependency-features>.
98
99 --default-features
100 Re-enable the default features
101 <https://doc.rust-lang.org/cargo/reference/features.html#dependency-features>.
102
103 --features features
104 Space or comma separated list of features to activate
105 <https://doc.rust-lang.org/cargo/reference/features.html#dependency-features>.
106 When adding multiple crates, the features for a specific crate may
107 be enabled with package-name/feature-name syntax. This flag may be
108 specified multiple times, which enables all specified features.
109
110 Display Options
111 -v, --verbose
112 Use verbose output. May be specified twice for "very verbose" output
113 which includes extra output such as dependency warnings and build
114 script output. May also be specified with the term.verbose config
115 value <https://doc.rust-lang.org/cargo/reference/config.html>.
116
117 -q, --quiet
118 Do not print cargo log messages. May also be specified with the
119 term.quiet config value
120 <https://doc.rust-lang.org/cargo/reference/config.html>.
121
122 --color when
123 Control when colored output is used. Valid values:
124
125 o auto (default): Automatically detect if color support is
126 available on the terminal.
127
128 o always: Always display colors.
129
130 o never: Never display colors.
131
132 May also be specified with the term.color config value
133 <https://doc.rust-lang.org/cargo/reference/config.html>.
134
135 Manifest Options
136 --manifest-path path
137 Path to the Cargo.toml file. By default, Cargo searches for the
138 Cargo.toml file in the current directory or any parent directory.
139
140 Common Options
141 +toolchain
142 If Cargo has been installed with rustup, and the first argument to
143 cargo begins with +, it will be interpreted as a rustup toolchain
144 name (such as +stable or +nightly). See the rustup documentation
145 <https://rust-lang.github.io/rustup/overrides.html> for more
146 information about how toolchain overrides work.
147
148 --config KEY=VALUE
149 Overrides a Cargo configuration value.
150
151 -h, --help
152 Prints help information.
153
154 -Z flag
155 Unstable (nightly-only) flags to Cargo. Run cargo -Z help for
156 details.
157
158 ENVIRONMENT
159 See the reference
160 <https://doc.rust-lang.org/cargo/reference/environment-variables.html>
161 for details on environment variables that Cargo reads.
162
163 EXIT STATUS
164 o 0: Cargo succeeded.
165
166 o 101: Cargo failed to complete.
167
168 EXAMPLES
169 1. Add regex as a dependency
170
171 cargo add regex
172
173 2. Add trybuild as a dev-dependency
174
175 cargo add --dev trybuild
176
177 3. Add an older version of nom as a dependency
178
179 cargo add nom@5
180
181 4. Add support for serializing data structures to json with derives
182
183 cargo add serde serde_json -F serde/derive
184
185 SEE ALSO
186 cargo(1)
187