DUB(1) | The D Language Foundation | DUB(1) |
NAME
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.
Custom templates can be defined by packages by providing a sub-package called "init-exec". No default source files are added in this case. The "init-exec" sub-package is compiled and executed inside the destination folder after the base project directory has been created. Free arguments "dub init -t custom -- free args" are passed into the "init-exec" sub-package as app arguments.
- 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
- When run with one or more arguments, regardless of the location it is run
in, it will fetch the packages matching the argument(s). Examples: $ dub
fetch vibe-d $ dub fetch vibe-d@v0.9.0 --cache=local --recursive
When run in a project with no arguments, it will fetch all dependencies for that project. If the project doesn't have set dependencies (no 'dub.selections.json'), it will also perform dependency resolution. Example: $ cd myProject && dub fetch
Note that the 'build', 'run', and any other command that need packages will automatically perform fetch, hence it is not generally necessary to run this command before any other.
- add
- Adds <packages> as dependencies.
Running "dub add <package>" is the same as adding <package> 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 a package (and optionally a version spec) is specified, only matching packages are shown.
- search
- Search all specified providers for matching packages.
- add-override
- This command is deprecated. Use path based dependency, custom cache path, or edit `dub.selections.json` to achieve the same results.
- remove-override
- This command is deprecated. Use path based dependency, custom cache path, or edit `dub.selections.json` to achieve the same results.
- list-overrides
- This command is deprecated. Use path based dependency, custom cache path, or edit `dub.selections.json` to achieve the same results.
- 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
--root=VALUE
--recipe=VALUE
--registry=VALUE
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
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
--bare
-v, --verbose
--vverbose
-q, --quiet
--verror
--vquiet
--color=VALUE
auto: Colored output on console/terminal,
unless NO_COLOR is set and non-empty (default)
always: Force colors enabled
never: Force colors disabled
--cache=VALUE
FILES
dub.sdl, dub.json
AUTHOR
Copyright (c) 1999-2024 by The D Language Foundation
ONLINE DOCUMENTATION
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)
2024-07-07 | The D Language Foundation |