blob: bd5f1bfe91c7c7b0e690094a0344b9690b716a06 [file] [log] [blame]
Matthew Maurerbd398542019-09-05 16:25:08 -07001'\" t
2.\" Title: cargo-run
3.\" Author: [see the "AUTHOR(S)" section]
4.\" Generator: Asciidoctor 1.5.8
5.\" Date: 2019-05-08
6.\" Manual: \ \&
7.\" Source: \ \&
8.\" Language: English
9.\"
10.TH "CARGO\-RUN" "1" "2019-05-08" "\ \&" "\ \&"
11.ie \n(.g .ds Aq \(aq
12.el .ds Aq '
13.ss \n[.ss] 0
14.nh
15.ad l
16.de URL
17\fI\\$2\fP <\\$1>\\$3
18..
19.als MTO URL
20.if \n[.g] \{\
21. mso www.tmac
22. am URL
23. ad l
24. .
25. am MTO
26. ad l
27. .
28. LINKSTYLE blue R < >
29.\}
30.SH "NAME"
31cargo\-run \- Run the current package
32.SH "SYNOPSIS"
33.sp
34\fBcargo run [\fIOPTIONS\fP] [\-\- \fIARGS\fP]\fP
35.SH "DESCRIPTION"
36.sp
37Run a binary or example of the local package.
38.sp
39All the arguments following the two dashes (\fB\-\-\fP) are passed to the binary to
40run. If you\(cqre passing arguments to both Cargo and the binary, the ones after
41\fB\-\-\fP go to the binary, the ones before go to Cargo.
42.SH "OPTIONS"
43.SS "Package Selection"
44.sp
45By default, the package in the current working directory is selected. The \fB\-p\fP
46flag can be used to choose a different package in a workspace.
47.sp
48\fB\-p\fP \fISPEC\fP, \fB\-\-package\fP \fISPEC\fP
49.RS 4
50The package to run. See \fBcargo\-pkgid\fP(1) for
51the SPEC format.
52.RE
53.SS "Target Selection"
54.sp
55When no target selection options are given, \fBcargo run\fP will run the binary
56target. If there are multiple binary targets, you must pass a target flag to
57choose one.
58.sp
59\fB\-\-bin\fP \fINAME\fP
60.RS 4
61Run the specified binary.
62.RE
63.sp
64\fB\-\-example\fP \fINAME\fP
65.RS 4
66Run the specified example.
67.RE
68.SS "Feature Selection"
69.sp
70When no feature options are given, the \fBdefault\fP feature is activated for
71every selected package.
72.sp
73\fB\-\-features\fP \fIFEATURES\fP
74.RS 4
75Space or comma separated list of features to activate. These features only
76apply to the current directory\(cqs package. Features of direct dependencies
77may be enabled with \fB<dep\-name>/<feature\-name>\fP syntax.
78.RE
79.sp
80\fB\-\-all\-features\fP
81.RS 4
82Activate all available features of all selected packages.
83.RE
84.sp
85\fB\-\-no\-default\-features\fP
86.RS 4
87Do not activate the \fBdefault\fP feature of the current directory\(cqs
88package.
89.RE
90.SS "Compilation Options"
91.sp
92\fB\-\-target\fP \fITRIPLE\fP
93.RS 4
94Run for the given architecture. The default is the host
95architecture. The general format of the triple is
96\fB<arch><sub>\-<vendor>\-<sys>\-<abi>\fP. Run \fBrustc \-\-print target\-list\fP for a
97list of supported targets.
98.sp
99This may also be specified with the \fBbuild.target\fP
100.URL "https://doc.rust\-lang.org/cargo/reference/config.html" "config value" "."
101.RE
102.sp
103\fB\-\-release\fP
104.RS 4
105Run optimized artifacts with the \fBrelease\fP profile. See the
106PROFILES section for details on how this affects profile selection.
107.RE
108.SS "Output Options"
109.sp
110\fB\-\-target\-dir\fP \fIDIRECTORY\fP
111.RS 4
112Directory for all generated artifacts and intermediate files. May also be
113specified with the \fBCARGO_TARGET_DIR\fP environment variable, or the
114\fBbuild.target\-dir\fP \c
115.URL "https://doc.rust\-lang.org/cargo/reference/config.html" "config value" "."
116Defaults
117to \fBtarget\fP in the root of the workspace.
118.RE
119.SS "Display Options"
120.sp
121\fB\-v\fP, \fB\-\-verbose\fP
122.RS 4
123Use verbose output. May be specified twice for "very verbose" output which
124includes extra output such as dependency warnings and build script output.
125May also be specified with the \fBterm.verbose\fP
126.URL "https://doc.rust\-lang.org/cargo/reference/config.html" "config value" "."
127.RE
128.sp
129\fB\-q\fP, \fB\-\-quiet\fP
130.RS 4
131No output printed to stdout.
132.RE
133.sp
134\fB\-\-color\fP \fIWHEN\fP
135.RS 4
136Control when colored output is used. Valid values:
137.sp
138.RS 4
139.ie n \{\
140\h'-04'\(bu\h'+03'\c
141.\}
142.el \{\
143. sp -1
144. IP \(bu 2.3
145.\}
146\fBauto\fP (default): Automatically detect if color support is available on the
147terminal.
148.RE
149.sp
150.RS 4
151.ie n \{\
152\h'-04'\(bu\h'+03'\c
153.\}
154.el \{\
155. sp -1
156. IP \(bu 2.3
157.\}
158\fBalways\fP: Always display colors.
159.RE
160.sp
161.RS 4
162.ie n \{\
163\h'-04'\(bu\h'+03'\c
164.\}
165.el \{\
166. sp -1
167. IP \(bu 2.3
168.\}
169\fBnever\fP: Never display colors.
170.RE
171.sp
172May also be specified with the \fBterm.color\fP
173.URL "https://doc.rust\-lang.org/cargo/reference/config.html" "config value" "."
174.RE
175.sp
176\fB\-\-message\-format\fP \fIFMT\fP
177.RS 4
178The output format for diagnostic messages. Valid values:
179.sp
180.RS 4
181.ie n \{\
182\h'-04'\(bu\h'+03'\c
183.\}
184.el \{\
185. sp -1
186. IP \(bu 2.3
187.\}
188\fBhuman\fP (default): Display in a human\-readable text format.
189.RE
190.sp
191.RS 4
192.ie n \{\
193\h'-04'\(bu\h'+03'\c
194.\}
195.el \{\
196. sp -1
197. IP \(bu 2.3
198.\}
199\fBjson\fP: Emit JSON messages to stdout.
200.RE
201.sp
202.RS 4
203.ie n \{\
204\h'-04'\(bu\h'+03'\c
205.\}
206.el \{\
207. sp -1
208. IP \(bu 2.3
209.\}
210\fBshort\fP: Emit shorter, human\-readable text messages.
211.RE
212.RE
213.SS "Manifest Options"
214.sp
215\fB\-\-manifest\-path\fP \fIPATH\fP
216.RS 4
217Path to the \fBCargo.toml\fP file. By default, Cargo searches in the current
218directory or any parent directory for the \fBCargo.toml\fP file.
219.RE
220.sp
221\fB\-\-frozen\fP, \fB\-\-locked\fP
222.RS 4
223Either of these flags requires that the \fBCargo.lock\fP file is
224up\-to\-date. If the lock file is missing, or it needs to be updated, Cargo will
225exit with an error. The \fB\-\-frozen\fP flag also prevents Cargo from
226attempting to access the network to determine if it is out\-of\-date.
227.sp
228These may be used in environments where you want to assert that the
229\fBCargo.lock\fP file is up\-to\-date (such as a CI build) or want to avoid network
230access.
231.RE
232.sp
233\fB\-\-offline\fP
234.RS 4
235Prevents Cargo from accessing the network for any reason. Without this
236flag, Cargo will stop with an error if it needs to access the network and
237the network is not available. With this flag, Cargo will attempt to
238proceed without the network if possible.
239.sp
240Beware that this may result in different dependency resolution than online
241mode. Cargo will restrict itself to crates that are downloaded locally, even
242if there might be a newer version as indicated in the local copy of the index.
243See the \fBcargo\-fetch\fP(1) command to download dependencies before going
244offline.
245.sp
246May also be specified with the \fBnet.offline\fP \c
247.URL "https://doc.rust\-lang.org/cargo/reference/config.html" "config value" "."
248.RE
249.SS "Common Options"
250.sp
251\fB\-h\fP, \fB\-\-help\fP
252.RS 4
253Prints help information.
254.RE
255.sp
256\fB\-Z\fP \fIFLAG\fP...
257.RS 4
258Unstable (nightly\-only) flags to Cargo. Run \fBcargo \-Z help\fP for
259details.
260.RE
261.SS "Miscellaneous Options"
262.sp
263\fB\-j\fP \fIN\fP, \fB\-\-jobs\fP \fIN\fP
264.RS 4
265Number of parallel jobs to run. May also be specified with the
266\fBbuild.jobs\fP \c
267.URL "https://doc.rust\-lang.org/cargo/reference/config.html" "config value" "."
268Defaults to
269the number of CPUs.
270.RE
271.SH "PROFILES"
272.sp
273Profiles may be used to configure compiler options such as optimization levels
274and debug settings. See
275\c
276.URL "https://doc.rust\-lang.org/cargo/reference/manifest.html#the\-profile\-sections" "the reference"
277for more details.
278.sp
279Profile selection depends on the target and crate being built. By default the
280\fBdev\fP or \fBtest\fP profiles are used. If the \fB\-\-release\fP flag is given, then the
281\fBrelease\fP or \fBbench\fP profiles are used.
282.TS
283allbox tab(:);
284lt lt lt.
285T{
286.sp
287Target
288T}:T{
289.sp
290Default Profile
291T}:T{
292.sp
293\fB\-\-release\fP Profile
294T}
295T{
296.sp
297lib, bin, example
298T}:T{
299.sp
300\fBdev\fP
301T}:T{
302.sp
303\fBrelease\fP
304T}
305T{
306.sp
307test, bench, or any target
308.br
309in "test" or "bench" mode
310T}:T{
311.sp
312\fBtest\fP
313T}:T{
314.sp
315\fBbench\fP
316T}
317.TE
318.sp
319.sp
320Dependencies use the \fBdev\fP/\fBrelease\fP profiles.
321.SH "ENVIRONMENT"
322.sp
323See \c
324.URL "https://doc.rust\-lang.org/cargo/reference/environment\-variables.html" "the reference" " "
325for
326details on environment variables that Cargo reads.
327.SH "EXIT STATUS"
328.sp
3290
330.RS 4
331Cargo succeeded.
332.RE
333.sp
334101
335.RS 4
336Cargo failed to complete.
337.RE
338.SH "EXAMPLES"
339.sp
340.RS 4
341.ie n \{\
342\h'-04' 1.\h'+01'\c
343.\}
344.el \{\
345. sp -1
346. IP " 1." 4.2
347.\}
348Build the local package and run its main target (assuming only one binary):
349.sp
350.if n .RS 4
351.nf
352cargo run
353.fi
354.if n .RE
355.RE
356.sp
357.RS 4
358.ie n \{\
359\h'-04' 2.\h'+01'\c
360.\}
361.el \{\
362. sp -1
363. IP " 2." 4.2
364.\}
365Run an example with extra arguments:
366.sp
367.if n .RS 4
368.nf
369cargo run \-\-example exname \-\- \-\-exoption exarg1 exarg2
370.fi
371.if n .RE
372.RE
373.SH "SEE ALSO"
374.sp
375\fBcargo\fP(1), \fBcargo\-build\fP(1)