Configuring default settings

User/System wide default DUB values can be specified in settings.json file.

A settings.json file could look like this:

{
	"defaultArchitecture": "x86_64",
	"defaultCompiler": "ldc"
}

The file settings.json can be located in different locations. Last item in list has highest priority.

Windows

Posix

Settings overview

NameTypeDescription
registryUrls string[] 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
skipRegistry string 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
customCachePaths string[]

Additional paths that contain packages in subfolders with the pattern "(name)-(version)/(name)/".

Can be used to provide prebuilt DUB libraries (e.g. for distribution package maintainers).

defaultCompiler string

Specifies the compiler binary to use (can be a path).

Arbitrary pre- and suffixes to the identifiers below are recognized (e.g. ldc2 or dmd-2.063) and matched to the proper compiler type: dmd, gdc, ldc, gdmd, ldmd

defaultArchitecture string Force a different architecture (e.g. x86 or x86_64)
defaultLowMemory bool Enable the garbage collector for the compiler(dmd/ldc), reducing the compiler memory requirements but increasing compile times.
defaultEnvironments string[string] Sets the keys in environments if they are not overriden by the dub recipe. Defines default environment variables used by all executable invocations. This has the lowest precedence.
defaultBuildEnvironments string[string] Sets the keys in buildEnvironments if they are not overriden by the dub recipe. Defines default environment variables used by build tools (compiler, linker), preBuildCommands, postBuildCommands, preGenerateCommands and postGenerateCommands invocations. Overrides keys from defaultEnvironments.
defaultRunEnvironments string[string] Sets the keys in runEnvironments if they are not overriden by the dub recipe. Defines default environment variables used by the built user program, preRunCommands and postRunCommands invocations. Overrides keys from defaultEnvironments.
defaultPreGenerateEnvironments string[string] Sets the keys in preGenerateEnvironments if they are not overriden by the dub recipe. Defines default environment variables used by preGenerateCommands invocations. Overrides keys from defaultEnvironments.
defaultPostGenerateEnvironments string[string] Sets the keys in postGenerateEnvironments if they are not overriden by the dub recipe. Defines default environment variables used by postGenerateCommands invocations. Overrides keys from defaultEnvironments.
defaultPreBuildEnvironments string[string] Sets the keys in preBuildEnvironments if they are not overriden by the dub recipe. Defines default environment variables used by preBuildCommands invocations. Overrides keys from defaultBuildEnvironments and defaultEnvironments.
defaultPostBuildEnvironments string[string] Sets the keys in postBuildEnvironments if they are not overriden by the dub recipe. Defines default environment variables used by postBuildCommands invocations. Overrides keys from defaultBuildEnvironments and defaultEnvironments.
defaultPreRunEnvironments string[string] Sets the keys in preRunEnvironments if they are not overriden by the dub recipe. Defines default environment variables used by preRunCommands invocations. Overrides keys from defaultRunEnvironments and defaultEnvironments.
defaultPostRunEnvironments string[string] Sets the keys in postRunEnvironments if they are not overriden by the dub recipe. Defines default environment variables used by postRunCommands invocations. Overrides keys from defaultRunEnvironments and defaultEnvironments.

Environment Variables

Environment variables are set by keys using the defaultEnvironments and related settings in the settings and with highest precedence environments and related settings in the package recipe.

For finding the default environment variables first the system environment variables are loaded, then overriden by the settings environment variables. This goes through all the default settings first.

Afterwards dependency or recipe environment variables override these default environment variables. Recipe variables have higher precedence than dependency variables.

Defining a generic environments block inside a dependency overrides the keys set by e.g. defaultPreRunEnvironments inside the settings.