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

ENVIRONMENT

128       See the reference
129       <https://doc.rust-lang.org/cargo/reference/environment-variables.html>
130       for details on environment variables that Cargo reads.
131

EXIT STATUS

133       ·  0: Cargo succeeded.
134
135       ·  101: Cargo failed to complete.
136

EXAMPLES

138        1. Remove the entire target directory:
139
140               cargo clean
141
142        2. Remove only the release artifacts:
143
144               cargo clean --release
145

SEE ALSO

147       cargo(1), cargo-build(1)
148
149
150
151                                                                CARGO-CLEAN(1)
Impressum