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

NAME

6       cargo-init - Create a new Cargo package in an existing directory
7

SYNOPSIS

9       cargo init [options] [path]
10

DESCRIPTION

12       This command will create a new Cargo manifest in the current directory.
13       Give a path as an argument to create in the given directory.
14
15       If there are typically-named Rust source files already in the
16       directory, those will be used. If not, then a sample src/main.rs file
17       will be created, or src/lib.rs if --lib is passed.
18
19       If the directory is not already in a VCS repository, then a new
20       repository is created (see --vcs below).
21
22       The "authors" field in the manifest is determined from the environment
23       or configuration settings. A name is required and is determined from
24       (first match wins):
25
26       ·  cargo-new.name Cargo config value
27
28       ·  CARGO_NAME environment variable
29
30       ·  GIT_AUTHOR_NAME environment variable
31
32       ·  GIT_COMMITTER_NAME environment variable
33
34       ·  user.name git configuration value
35
36       ·  USER environment variable
37
38       ·  USERNAME environment variable
39
40       ·  NAME environment variable
41
42       The email address is optional and is determined from:
43
44       ·  cargo-new.email Cargo config value
45
46       ·  CARGO_EMAIL environment variable
47
48       ·  GIT_AUTHOR_EMAIL environment variable
49
50       ·  GIT_COMMITTER_EMAIL environment variable
51
52       ·  user.email git configuration value
53
54       ·  EMAIL environment variable
55
56       See the reference
57       <https://doc.rust-lang.org/cargo/reference/config.html> for more
58       information about configuration files.
59
60       See cargo-new(1) for a similar command which will create a new package
61       in a new directory.
62

OPTIONS

64   Init Options
65       --bin
66           Create a package with a binary target (src/main.rs). This is the
67           default behavior.
68
69       --lib
70           Create a package with a library target (src/lib.rs).
71
72       --edition edition
73           Specify the Rust edition to use. Default is 2018. Possible values:
74           2015, 2018, 2021
75
76       --name name
77           Set the package name. Defaults to the directory name.
78
79       --vcs vcs
80           Initialize a new VCS repository for the given version control
81           system (git, hg, pijul, or fossil) or do not initialize any version
82           control at all (none). If not specified, defaults to git or the
83           configuration value cargo-new.vcs, or none if already inside a VCS
84           repository.
85
86       --registry registry
87           This sets the publish field in Cargo.toml to the given registry
88           name which will restrict publishing only to that registry.
89
90           Registry names are defined in Cargo config files
91           <https://doc.rust-lang.org/cargo/reference/config.html>. If not
92           specified, the default registry defined by the registry.default
93           config key is used. If the default registry is not set and
94           --registry is not used, the publish field will not be set which
95           means that publishing will not be restricted.
96
97   Display Options
98       -v, --verbose
99           Use verbose output. May be specified twice for "very verbose"
100           output which includes extra output such as dependency warnings and
101           build script output. May also be specified with the term.verbose
102           config value
103           <https://doc.rust-lang.org/cargo/reference/config.html>.
104
105       -q, --quiet
106           No output printed to stdout.
107
108       --color when
109           Control when colored output is used. Valid values:
110
111           ·  auto (default): Automatically detect if color support is
112               available on the terminal.
113
114           ·  always: Always display colors.
115
116           ·  never: Never display colors.
117
118           May also be specified with the term.color config value
119           <https://doc.rust-lang.org/cargo/reference/config.html>.
120
121   Common Options
122       +toolchain
123           If Cargo has been installed with rustup, and the first argument to
124           cargo begins with +, it will be interpreted as a rustup toolchain
125           name (such as +stable or +nightly). See the rustup documentation
126           <https://rust-lang.github.io/rustup/overrides.html> for more
127           information about how toolchain overrides work.
128
129       -h, --help
130           Prints help information.
131
132       -Z flag
133           Unstable (nightly-only) flags to Cargo. Run cargo -Z help for
134           details.
135

ENVIRONMENT

137       See the reference
138       <https://doc.rust-lang.org/cargo/reference/environment-variables.html>
139       for details on environment variables that Cargo reads.
140

EXIT STATUS

142       ·  0: Cargo succeeded.
143
144       ·  101: Cargo failed to complete.
145

EXAMPLES

147        1. Create a binary Cargo package in the current directory:
148
149               cargo init
150

SEE ALSO

152       cargo(1), cargo-new(1)
153
154
155
156                                                                 CARGO-INIT(1)
Impressum