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

NAME

6       cargo-new — Create a new Cargo package
7

SYNOPSIS

9       cargo new [options] path
10

DESCRIPTION

12       This command will create a new Cargo package in the given directory.
13       This includes a simple template with a Cargo.toml manifest, sample
14       source file, and a VCS ignore file. If the directory is not already in
15       a VCS repository, then a new repository is created (see --vcs below).
16
17       See cargo-init(1) for a similar command which will create a new
18       manifest in an existing directory.
19

OPTIONS

21   New Options
22       --bin
23           Create a package with a binary target (src/main.rs). This is the
24           default behavior.
25
26       --lib
27           Create a package with a library target (src/lib.rs).
28
29       --edition edition
30           Specify the Rust edition to use. Default is 2021. Possible values:
31           2015, 2018, 2021
32
33       --name name
34           Set the package name. Defaults to the directory name.
35
36       --vcs vcs
37           Initialize a new VCS repository for the given version control
38           system (git, hg, pijul, or fossil) or do not initialize any version
39           control at all (none). If not specified, defaults to git or the
40           configuration value cargo-new.vcs, or none if already inside a VCS
41           repository.
42
43       --registry registry
44           This sets the publish field in Cargo.toml to the given registry
45           name which will restrict publishing only to that registry.
46
47           Registry names are defined in Cargo config files
48           <https://doc.rust-lang.org/cargo/reference/config.html>. If not
49           specified, the default registry defined by the registry.default
50           config key is used. If the default registry is not set and
51           --registry is not used, the publish field will not be set which
52           means that publishing will not be restricted.
53
54   Display Options
55       -v, --verbose
56           Use verbose output. May be specified twice for “very verbose”
57           output which includes extra output such as dependency warnings and
58           build script output. May also be specified with the term.verbose
59           config value
60           <https://doc.rust-lang.org/cargo/reference/config.html>.
61
62       -q, --quiet
63           Do not print cargo log messages. May also be specified with the
64           term.quiet config value
65           <https://doc.rust-lang.org/cargo/reference/config.html>.
66
67       --color when
68           Control when colored output is used. Valid values:
69
70auto (default): Automatically detect if color support is
71               available on the terminal.
72
73always: Always display colors.
74
75never: Never display colors.
76
77           May also be specified with the term.color config value
78           <https://doc.rust-lang.org/cargo/reference/config.html>.
79
80   Common Options
81       +toolchain
82           If Cargo has been installed with rustup, and the first argument to
83           cargo begins with +, it will be interpreted as a rustup toolchain
84           name (such as +stable or +nightly). See the rustup documentation
85           <https://rust-lang.github.io/rustup/overrides.html> for more
86           information about how toolchain overrides work.
87
88       --config KEY=VALUE or PATH
89           Overrides a Cargo configuration value. The argument should be in
90           TOML syntax of KEY=VALUE, or provided as a path to an extra
91           configuration file. This flag may be specified multiple times. See
92           the command-line overrides section
93           <https://doc.rust-lang.org/cargo/reference/config.html#command-line-overrides>
94           for more information.
95
96       -C PATH
97           Changes the current working directory before executing any
98           specified operations. This affects things like where cargo looks by
99           default for the project manifest (Cargo.toml), as well as the
100           directories searched for discovering .cargo/config.toml, for
101           example. This option must appear before the command name, for
102           example cargo -C path/to/my-project build.
103
104           This option is only available on the nightly channel
105           <https://doc.rust-lang.org/book/appendix-07-nightly-rust.html> and
106           requires the -Z unstable-options flag to enable (see #10098
107           <https://github.com/rust-lang/cargo/issues/10098>).
108
109       -h, --help
110           Prints help information.
111
112       -Z flag
113           Unstable (nightly-only) flags to Cargo. Run cargo -Z help for
114           details.
115

ENVIRONMENT

117       See the reference
118       <https://doc.rust-lang.org/cargo/reference/environment-variables.html>
119       for details on environment variables that Cargo reads.
120

EXIT STATUS

1220: Cargo succeeded.
123
124101: Cargo failed to complete.
125

EXAMPLES

127        1. Create a binary Cargo package in the given directory:
128
129               cargo new foo
130

SEE ALSO

132       cargo(1), cargo-init(1)
133
134
135
136                                                                  CARGO-NEW(1)
Impressum