Skip to content

dub(1)

dub - Package and build management system for D

SYNOPSIS

dub [--version] [COMMAND] [OPTIONS...] -- [APPLICATION ARGUMENTS...]

DESCRIPTION

Manages the DUB project in the current directory. DUB can serve as a build system and a package manager, automatically keeping track of project's dependencies - both downloading them and linking them into the application.

COMMANDS

init
Initializes an empty package of the specified type in the given directory. By default, the current working directory is used.
run
Builds and runs a package (uses the main package in the current working directory by default)
build
Builds a package (uses the main package in the current working directory by default)
test
Builds the package and executes all contained unit tests. If no explicit configuration is given, an existing "unittest" configuration will be preferred for testing. If none exists, the first library type configuration will be used, and if that doesn't exist either, the first executable configuration is chosen. When a custom main file (--main-file) is specified, only library configurations can be used. Otherwise, depending on the type of the selected configuration, either an existing main file will be used (and needs to be properly adjusted to just run the unit tests for 'version(unittest)'), or DUB will generate one for library type configurations. Finally, if the package contains a dependency to the "tested" package, the automatically generated main file will use it to run the unit tests.
lint
Builds the package and executes D-Scanner linter tests.
generate
Generates project files using one of the supported generators: visuald - VisualD project files sublimetext - SublimeText project file cmake - CMake build scripts build - Builds the package directly An optional package name can be given to generate a different package than the root/CWD package.
describe
Prints a JSON build description for the root package an all of their dependencies in a format similar to a JSON package description file. This is useful mostly for IDEs. All usual options that are also used for build/run/generate apply. When --data=VALUE is supplied, specific build settings for a project will be printed instead (by default, formatted for the current compiler). The --data=VALUE option can be specified multiple times to retrieve several pieces of information at once. A comma-separated list is also acceptable (ex: --data=dflags,libs). The data will be output in the same order requested on the command line. The accepted values for --data=VALUE are: main-source-file, dflags, lflags, libs, linker-files, source-files, versions, debug-versions, import-paths, string-import-paths, import-files, options The following are also accepted by --data if --data-list is used: target-type, target-path, target-name, working-directory, copy-files, string-import-files, pre-generate-commands, post-generate-commands, pre-build-commands, post-build-commands, pre-run-commands, post-run-commands, requirements
clean
This command removes any cached build files of the given package(s). The final target file, as well as any copyFiles are currently not removed. Without arguments, the package in the current working directory will be cleaned.
dustmite
This command uses the Dustmite utility to isolate the cause of build errors in a DUB project. It will create a copy of all involved packages and run dustmite on this copy, leaving a reduced test case. Determining the desired error condition is done by checking the compiler/linker status code, as well as their output (stdout and stderr combined). If --program-status or --program-regex is given and the generated binary is an executable, it will be executed and its output will also be incorporated into the final decision.
fetch
Note: Use "dub add " if you just want to use a certain package as a dependency, you don't have to explicitly fetch packages. Explicit retrieval/removal of packages is only needed when you want to put packages in a place where several applications can share them. If you just have a dependency to add, use the add command. Dub will do the rest for you. Without specified options, placement/removal will default to a user wide shared location. Complete applications can be retrieved and run easily by e.g. $ dub fetch vibelog --cache=local $ dub run vibelog --cache=local This will grab all needed dependencies and compile and run the application.
add
Adds as dependencies. Running "dub add " is the same as adding to the "dependencies" section in dub.json/dub.sdl. If no version is specified for one of the packages, dub will query the registry for the latest version.
remove
Removes a package that is cached on the local system.
upgrade
Upgrades all dependencies of the package by querying the package registry(ies) for new versions. This will update the versions stored in the selections file (dub.selections.json) accordingly. If one or more package names are specified, only those dependencies will be upgraded. Otherwise all direct and indirect dependencies of the root package will get upgraded.
add-path
Adds a default package search path. All direct sub folders of this path will be searched for package descriptions and will be made available as packages. Using this command has the equivalent effect as calling 'dub add-local' on each of the sub folders manually. Any packages registered using add-path will be preferred over packages downloaded from the package registry when searching for dependencies during a build operation. The version of the packages will be determined by one of the following: - For GIT working copies, the last tag (git describe) is used to determine the version - If the package contains a "version" field in the package description, this is used - If neither of those apply, "~master" is assumed
remove-path
Removes a package search path previously added with add-path.
add-local
Adds a local package directory to be used during dependency resolution. This command is useful for registering local packages, such as GIT working copies, that are either not available in the package registry, or are supposed to be overwritten. The version of the package is either determined automatically (see the "add-path" command, or can be explicitly overwritten by passing a version on the command line. See 'dub add-path -h' for a way to register multiple local packages at once.
remove-local
Removes a local package directory
list
Prints a list of all or selected local packages. This includes all cached packages (user or system wide), all packages in the package search paths ("dub add-path") and all manually registered packages ("dub add-local"). If package specified output filtered by package spec.
search
Search all specified DUB registries for packages matching query.
add-override
remove-override
list-overrides
Prints a list of all overridden packages added via "dub add-override".
clean-caches
This command removes any cached metadata like the list of available packages and their latest version.
convert
This command will convert between JSON and SDLang formatted package recipe files. Warning: Beware that any formatting and comments within the package recipe will get lost in the conversion process.

COMMON OPTIONS

-h, --help
Display general or command specific help
--root=VALUE
Path to operate in instead of the current working dir
--registry=VALUE
Search the given registry URL first when resolving dependencies. Can be specified multiple times. Available registry types: DUB: URL to DUB registry (default) Maven: URL to Maven repository + group id containing dub packages as artifacts. E.g. mvn+http://localhost:8040/maven/libs-release/dubpackages
--skip-registry=VALUE
Sets a mode for skipping the search on certain package registry types: none: Search all configured or default registries (default) standard: Don't search the main registry (e.g. https://code.dlang.org/) configured: Skip all default and user configured registries all: Only search registries specified with --registry
--annotate
Do not perform any action, just print what would be done
--bare
Read only packages contained in the current directory
-v, --verbose
Print diagnostic output
--vverbose
Print debug output
-q, --quiet
Only print warnings and errors
--verror
Only print errors
--vquiet
Print no messages
--colors=VALUE
Configure colored output. Accepted values: automatic: Colored output on console/terminal, unless NO_COLOR is set and non-empty (default) on: Force colors enabled off: Force colors disabled
--cache=VALUE
Puts any fetched packages in the specified location [local|system|user].

FILES

dub.sdl, dub.json

AUTHOR

Copyright (c) 1999-2022 by The D Language Foundation

ONLINE DOCUMENTATION

http://code.dlang.org/docs/commandline

SEE ALSO

dmd(1), rdmd(1), dub-init(1), dub-run(1), dub-build(1), dub-test(1), dub-lint(1), dub-generate(1), dub-describe(1), dub-clean(1), dub-dustmite(1), dub-fetch(1), dub-add(1), dub-remove(1), dub-upgrade(1), dub-add-path(1), dub-remove-path(1), dub-add-local(1), dub-remove-local(1), dub-list(1), dub-search(1), dub-add-override(1), dub-remove-override(1), dub-list-overrides(1), dub-clean-caches(1), dub-convert(1)


Last update: August 5, 2022
Created: August 5, 2022