← 返回命令列表

Linux command

dub 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Build project

dub build

Run project

dub run

Initialize new project

dub init [name]

Add dependency

dub add [package]

Update dependencies

dub upgrade

Run tests

dub test

Build documentation

dub build --build=docs

Fetch dependencies only

dub fetch [package]

说明

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.

FAQ

What is the dub command used for?

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.

How do I run a basic dub example?

Run `dub build` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

Where can I find more dub examples?

This page includes 8 examples for dub, plus related commands for nearby Linux tasks.