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       -h, --help
97           Prints help information.
98
99       -Z flag
100           Unstable (nightly-only) flags to Cargo. Run cargo -Z help for
101           details.
102

ENVIRONMENT

104       See the reference
105       <https://doc.rust-lang.org/cargo/reference/environment-variables.html>
106       for details on environment variables that Cargo reads.
107

EXIT STATUS

1090: Cargo succeeded.
110
111101: Cargo failed to complete.
112

EXAMPLES

114        1. Create a binary Cargo package in the given directory:
115
116               cargo new foo
117

SEE ALSO

119       cargo(1), cargo-init(1)
120
121
122
123                                                                  CARGO-NEW(1)
Impressum