LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

dub

D language package manager and build tool

TLDR

Build project
$ dub build
copy
Run project
$ dub run
copy
Initialize new project
$ dub init [name]
copy
Add dependency
$ dub add [package]
copy
Update dependencies
$ dub upgrade
copy
Run tests
$ dub test
copy
Build documentation
$ dub build --build=docs
copy
Fetch dependencies only
$ dub fetch [package]
copy

SYNOPSIS

dub command [options]

DESCRIPTION

dub is the official package manager and build tool for the D programming language. It handles dependency management, project compilation, testing, and distribution, providing a complete project lifecycle management solution for D developers.The tool uses a JSON or SDL (Simple Declarative Language) configuration file (dub.json or dub.sdl) to describe project structure, dependencies, build configurations, and metadata. Dependencies are automatically fetched from the DUB registry (code.dlang.org) and cached locally.dub supports multiple build configurations (debug, release, unittest), allowing developers to define different compiler flags and dependencies for various scenarios. It can generate project files for IDEs and integrates with D compilers (dmd, ldc, gdc) automatically.The package ecosystem revolves around semantic versioning, with dub resolving dependency trees and selecting compatible versions. Projects can specify exact versions, version ranges, or branch references for dependencies. The upgrade command updates dependencies while respecting version constraints.

CONFIGURATION

dub.json or dub.sdl

Project configuration file defining dependencies, build settings, and metadata.
~/.dub/settings.json
User-level DUB settings including custom registry URLs and default paths.

SUBCOMMANDS

build

Build project.
run
Build and run.
test
Run unit tests.
init
Initialize new project.
add
Add dependency.
remove
Remove dependency.
upgrade
Upgrade dependencies.
fetch
Fetch package.
clean
Clean build artifacts.
describe
Show project description.
search
Search the package registry.
list
List installed packages.

COMMON OPTIONS

--build=TYPE

Build type: debug, release, release-debug, unittest, profile, docs.
--compiler=NAME
Use a specific compiler (dmd, ldc2, gdc).
--arch=ARCH
Force a specific target architecture (e.g. x86_64).
--config=NAME
Use a specific build configuration from dub.json.
-v, --verbose
Print verbose output.

INSTALL

sudo apt install dub
copy
sudo dnf install dub
copy
sudo pacman -S dub
copy
sudo apk add dub
copy
sudo zypper install dub
copy
brew install dub
copy
nix profile install nixpkgs#dub
copy

SEE ALSO

dmd(1), ldc(1)

Copied to clipboard
Kai