1DUB(1) The D Language Foundation DUB(1)
2
3
4
6 dub - Package and build management system for D
7
9 dub [--version] [COMMAND] [OPTIONS...] [-- [APPLICATION ARGUMENTS...]]
10
12 Manages the DUB project in the current directory. DUB can serve as a
13 build system and a package manager, automatically keeping track of
14 project's dependencies - both downloading them and linking them into
15 the application.
16
18 init Initializes an empty package of the specified type in the given
19 directory. By default, the current working directory is used.
20
21 run Builds and runs a package (uses the main package in the current
22 working directory by default)
23
24 build Builds a package (uses the main package in the current working
25 directory by default)
26
27 test Builds the package and executes all contained unit tests.
28
29 If no explicit configuration is given, an existing "unittest"
30 configuration will be preferred for testing. If none exists, the
31 first library type configuration will be used, and if that
32 doesn't exist either, the first executable configuration is cho‐
33 sen.
34
35 When a custom main file (--main-file) is specified, only library
36 configurations can be used. Otherwise, depending on the type of
37 the selected configuration, either an existing main file will be
38 used (and needs to be properly adjusted to just run the unit
39 tests for 'version(unittest)'), or DUB will generate one for li‐
40 brary type configurations.
41
42 Finally, if the package contains a dependency to the "tested"
43 package, the automatically generated main file will use it to
44 run the unit tests.
45
46 lint Builds the package and executes D-Scanner linter tests.
47
48 generate
49 Generates project files using one of the supported generators:
50
51 visuald - VisualD project files sublimetext - SublimeText
52 project file cmake - CMake build scripts build - Builds the
53 package directly
54
55 An optional package name can be given to generate a different
56 package than the root/CWD package.
57
58 describe
59 Prints a JSON build description for the root package an all of
60 their dependencies in a format similar to a JSON package de‐
61 scription file. This is useful mostly for IDEs.
62
63 All usual options that are also used for build/run/generate ap‐
64 ply.
65
66 When --data=VALUE is supplied, specific build settings for a
67 project will be printed instead (by default, formatted for the
68 current compiler).
69
70 The --data=VALUE option can be specified multiple times to re‐
71 trieve several pieces of information at once. A comma-separated
72 list is also acceptable (ex: --data=dflags,libs). The data will
73 be output in the same order requested on the command line.
74
75 The accepted values for --data=VALUE are:
76
77 main-source-file, dflags, lflags, libs, linker-files, source-
78 files, versions, debug-versions, import-paths, string-import-
79 paths, import-files, options
80
81 The following are also accepted by --data if --data-list is
82 used:
83
84 target-type, target-path, target-name, working-directory, copy-
85 files, string-import-files, pre-generate-commands, post-gener‐
86 ate-commands, pre-build-commands, post-build-commands, require‐
87 ments
88
89 clean This command removes any cached build files of the given pack‐
90 age(s). The final target file, as well as any copyFiles are cur‐
91 rently not removed. Without arguments, the package in the cur‐
92 rent working directory will be cleaned.
93
94 dustmite
95 This command uses the Dustmite utility to isolate the cause of
96 build errors in a DUB project.
97
98 It will create a copy of all involved packages and run dustmite
99 on this copy, leaving a reduced test case.
100
101 Determining the desired error condition is done by checking the
102 compiler/linker status code, as well as their output (stdout and
103 stderr combined). If --program-status or --program-regex is
104 given and the generated binary is an executable, it will be exe‐
105 cuted and its output will also be incorporated into the final
106 decision.
107
108 fetch Note: Use "dub add <dependency>" if you just want to use a cer‐
109 tain package as a dependency, you don't have to explicitly fetch
110 packages.
111
112 Explicit retrieval/removal of packages is only needed when you
113 want to put packages in a place where several applications can
114 share them. If you just have a dependency to add, use the `add`
115 command. Dub will do the rest for you.
116
117 Without specified options, placement/removal will default to a
118 user wide shared location.
119
120 Complete applications can be retrieved and run easily by e.g. $
121 dub fetch vibelog --cache=local $ dub run vibelog --cache=local
122
123 This will grab all needed dependencies and compile and run the
124 application.
125
126 Note: DUB does not do a system installation of packages. Pack‐
127 ages are instead only registered within DUB's internal ecosys‐
128 tem. Generation of native system packages/installers may be
129 added later as a separate feature.
130
131 install
132 Note: Use "dub add <dependency>" if you just want to use a cer‐
133 tain package as a dependency, you don't have to explicitly fetch
134 packages.
135
136 Explicit retrieval/removal of packages is only needed when you
137 want to put packages in a place where several applications can
138 share them. If you just have a dependency to add, use the `add`
139 command. Dub will do the rest for you.
140
141 Without specified options, placement/removal will default to a
142 user wide shared location.
143
144 Complete applications can be retrieved and run easily by e.g. $
145 dub fetch vibelog --cache=local $ dub run vibelog --cache=local
146
147 This will grab all needed dependencies and compile and run the
148 application.
149
150 Note: DUB does not do a system installation of packages. Pack‐
151 ages are instead only registered within DUB's internal ecosys‐
152 tem. Generation of native system packages/installers may be
153 added later as a separate feature.
154
155 add Adds <packages> as dependencies.
156
157 Running "dub add <package>" is the same as adding <package> to
158 the "dependencies" section in dub.json/dub.sdl. If no version
159 is specified for one of the packages, dub will query the reg‐
160 istry for the latest version.
161
162 remove Removes a package that is cached on the local system.
163
164 uninstall
165 Removes a package that is cached on the local system.
166
167 upgrade
168 Upgrades all dependencies of the package by querying the package
169 registry(ies) for new versions.
170
171 This will update the versions stored in the selections file
172 (dub.selections.json) accordingly.
173
174 If one or more package names are specified, only those dependen‐
175 cies will be upgraded. Otherwise all direct and indirect depen‐
176 dencies of the root package will get upgraded.
177
178 add-path
179 Adds a default package search path. All direct sub folders of
180 this path will be searched for package descriptions and will be
181 made available as packages. Using this command has the equiva‐
182 lent effect as calling 'dub add-local' on each of the sub fold‐
183 ers manually.
184
185 Any packages registered using add-path will be preferred over
186 packages downloaded from the package registry when searching for
187 dependencies during a build operation.
188
189 The version of the packages will be determined by one of the
190 following:
191 - For GIT working copies, the last tag (git describe) is used
192 to determine the version
193 - If the package contains a "version" field in the package de‐
194 scription, this is used
195 - If neither of those apply, "~master" is assumed
196
197 remove-path
198 Removes a package search path previously added with add-path.
199
200 add-local
201 Adds a local package directory to be used during dependency res‐
202 olution. This command is useful for registering local packages,
203 such as GIT working copies, that are either not available in the
204 package registry, or are supposed to be overwritten.
205
206 The version of the package is either determined automatically
207 (see the "add-path" command, or can be explicitly overwritten by
208 passing a version on the command line.
209
210 See 'dub add-path -h' for a way to register multiple local pack‐
211 ages at once.
212
213 remove-local
214 Removes a local package directory
215
216 list Prints a list of all local packages. This includes all cached
217 packages (user or system wide), all packages in the package
218 search paths ("dub add-path") and all manually registered pack‐
219 ages ("dub add-local").
220
221 search Search all specified DUB registries for packages matching query.
222
223 add-override
224
225
226 remove-override
227
228
229 list-overrides
230 Prints a list of all overridden packages added via "dub add-
231 override".
232
233 clean-caches
234 This command removes any cached metadata like the list of avail‐
235 able packages and their latest version.
236
237 convert
238 This command will convert between JSON and SDLang formatted
239 package recipe files.
240
241 Warning: Beware that any formatting and comments within the
242 package recipe will get lost in the conversion process.
243
245 -h, Display general or command specific help
246
247 --root=VALUE
248 Path to operate in instead of the current working dir
249
250 --registry=VALUE
251 Search the given registry URL first when resolving dependencies.
252 Can be specified multiple times. Available registry types:
253 DUB: URL to DUB registry (default)
254 Maven: URL to Maven repository + group id containing dub pack‐
255 ages as artifacts. E.g. mvn+http://localhost:8040/maven/libs-re‐
256 lease/dubpackages
257
258 --skip-registry=VALUE
259 Sets a mode for skipping the search on certain package registry
260 types:
261 none: Search all configured or default registries (default)
262 standard: Don't search the main registry (e.g.
263 https://code.dlang.org/)
264 configured: Skip all default and user configured registries
265 all: Only search registries specified with --registry
266
267 --annotate
268 Do not perform any action, just print what would be done
269
270 --bare Read only packages contained in the current directory
271
272 -v, Print diagnostic output
273
274 --vverbose
275 Print debug output
276
277 -q, Only print warnings and errors
278
279 --verror
280 Only print errors
281
282 --vquiet
283 Print no messages
284
285 --cache=VALUE
286 Puts any fetched packages in the specified location [local|sys‐
287 tem|user].
288
290 dub.sdl, dub.json
291
293 Copyright (c) 1999-2022 by The D Language Foundation
294
296 ⟨http://code.dlang.org/docs/commandline⟩http://code.dlang.org/docs/commandline
297
299 dmd(1), rdmd(1), dub-init(1), dub-run(1), dub-build(1), dub-test(1),
300 dub-lint(1), dub-generate(1), dub-describe(1), dub-clean(1), dub-dust‐
301 mite(1), dub-fetch(1), dub-install(1), dub-add(1), dub-remove(1), dub-
302 uninstall(1), dub-upgrade(1), dub-add-path(1), dub-remove-path(1), dub-
303 add-local(1), dub-remove-local(1), dub-list(1), dub-search(1), dub-add-
304 override(1), dub-remove-override(1), dub-list-overrides(1), dub-clean-
305 caches(1), dub-convert(1)
306
307
308
309The D Language Foundation 2022-01-20 DUB(1)