1CARGO-CLEAN(1)              General Commands Manual             CARGO-CLEAN(1)
2
3
4

NAME

6       cargo-clean - Remove generated artifacts
7

SYNOPSIS

9       cargo clean [options]
10

DESCRIPTION

12       Remove artifacts from the target directory that Cargo has generated in
13       the past.
14
15       With no options, cargo clean will delete the entire target directory.
16

OPTIONS

18   Package Selection
19       When no packages are selected, all packages and all dependencies in the
20       workspace are cleaned.
21
22       -p spec..., --package spec...
23           Clean only the specified packages. This flag may be specified
24           multiple times. See cargo-pkgid(1) for the SPEC format.
25
26   Clean Options
27       --doc
28           This option will cause cargo clean to remove only the doc directory
29           in the target directory.
30
31       --release
32           Remove all artifacts in the release directory.
33
34       --profile name
35           Remove all artifacts in the directory with the given profile name.
36
37       --target-dir directory
38           Directory for all generated artifacts and intermediate files. May
39           also be specified with the CARGO_TARGET_DIR environment variable,
40           or the build.target-dir config value
41           <https://doc.rust-lang.org/cargo/reference/config.html>. Defaults
42           to target in the root of the workspace.
43
44       --target triple
45           Clean for the given architecture. The default is the host
46           architecture. The general format of the triple is
47           <arch><sub>-<vendor>-<sys>-<abi>. Run rustc --print target-list for
48           a list of supported targets.
49
50           This may also be specified with the build.target config value
51           <https://doc.rust-lang.org/cargo/reference/config.html>.
52
53           Note that specifying this flag makes Cargo run in a different mode
54           where the target artifacts are placed in a separate directory. See
55           the build cache
56           <https://doc.rust-lang.org/cargo/guide/build-cache.html>
57           documentation for more details.
58
59   Display Options
60       -v, --verbose
61           Use verbose output. May be specified twice for "very verbose"
62           output which includes extra output such as dependency warnings and
63           build script output. May also be specified with the term.verbose
64           config value
65           <https://doc.rust-lang.org/cargo/reference/config.html>.
66
67       -q, --quiet
68           Do not print cargo log messages. May also be specified with the
69           term.quiet config value
70           <https://doc.rust-lang.org/cargo/reference/config.html>.
71
72       --color when
73           Control when colored output is used. Valid values:
74
75auto (default): Automatically detect if color support is
76               available on the terminal.
77
78always: Always display colors.
79
80never: Never display colors.
81
82           May also be specified with the term.color config value
83           <https://doc.rust-lang.org/cargo/reference/config.html>.
84
85   Manifest Options
86       --manifest-path path
87           Path to the Cargo.toml file. By default, Cargo searches for the
88           Cargo.toml file in the current directory or any parent directory.
89
90       --frozen, --locked
91           Either of these flags requires that the Cargo.lock file is
92           up-to-date. If the lock file is missing, or it needs to be updated,
93           Cargo will exit with an error. The --frozen flag also prevents
94           Cargo from attempting to access the network to determine if it is
95           out-of-date.
96
97           These may be used in environments where you want to assert that the
98           Cargo.lock file is up-to-date (such as a CI build) or want to avoid
99           network access.
100
101       --offline
102           Prevents Cargo from accessing the network for any reason. Without
103           this flag, Cargo will stop with an error if it needs to access the
104           network and the network is not available. With this flag, Cargo
105           will attempt to proceed without the network if possible.
106
107           Beware that this may result in different dependency resolution than
108           online mode. Cargo will restrict itself to crates that are
109           downloaded locally, even if there might be a newer version as
110           indicated in the local copy of the index. See the cargo-fetch(1)
111           command to download dependencies before going offline.
112
113           May also be specified with the net.offline config value
114           <https://doc.rust-lang.org/cargo/reference/config.html>.
115
116   Common Options
117       +toolchain
118           If Cargo has been installed with rustup, and the first argument to
119           cargo begins with +, it will be interpreted as a rustup toolchain
120           name (such as +stable or +nightly). See the rustup documentation
121           <https://rust-lang.github.io/rustup/overrides.html> for more
122           information about how toolchain overrides work.
123
124       -h, --help
125           Prints help information.
126
127       -Z flag
128           Unstable (nightly-only) flags to Cargo. Run cargo -Z help for
129           details.
130

ENVIRONMENT

132       See the reference
133       <https://doc.rust-lang.org/cargo/reference/environment-variables.html>
134       for details on environment variables that Cargo reads.
135

EXIT STATUS

1370: Cargo succeeded.
138
139101: Cargo failed to complete.
140

EXAMPLES

142        1. Remove the entire target directory:
143
144               cargo clean
145
146        2. Remove only the release artifacts:
147
148               cargo clean --release
149

SEE ALSO

151       cargo(1), cargo-build(1)
152
153
154
155                                                                CARGO-CLEAN(1)
Impressum