Environment Variables
Work-in-Progress Documentation
The content on this page is not yet fully finished.
Tracking issue: https://github.com/dlang/dub-docs/issues/65
Environment variables DUB reads
DUB_HOME
DPATH
DFLAGS
http_proxy
no_proxy
NO_COLOR
TEMP
(Windows only)DUB_NO_RESOLVE_LIMIT
DUB_REGISTRY
DUBPATH
DC
PATH
ProgramData
(Windows only)APPDATA
(Windows only)HOME
(POSIX only)USERNAME
(Windows only)USER
(POSIX only)
set by dub in commands:
PACKAGE_DIR
- Path to the package itselfROOT_PACKAGE_DIR
- Path to the root package of the build dependency tree<PKG>_PACKAGE_DIR
- Path to a specific package that is part of the package's dependency graph. $must be in uppercase letters without the semver string. DUB
- Path to the DUB executableDUB_PACKAGE
- Name of the packageDUB_PACKAGE_VERSION
- Version of the packageDUB_ROOT_PACKAGE
- Name of the root package that is being builtDUB_ROOT_PACKAGE_TARGET_TYPE
- Contents of the "targetType" field of the root package as defined by the package recipeDUB_ROOT_PACKAGE_TARGET_PATH
- Contents of the "targetPath" field of the root package as defined by the package recipeDUB_ROOT_PACKAGE_TARGET_NAME
- Contents of the "targetName" field of the root package as defined by the package recipeDFLAGS
- Contents of the "dflags" field as defined by the package recipeLFLAGS
- Contents of the "lflags" field as defined by the package recipeVERSIONS
- Contents of the "versions" field as defined by the package recipeLIBS
- Contents of the "libs" field as defined by the package recipeSOURCE_FILES
- Contents of the "sourceFiles" field as defined by the package recipeIMPORT_PATHS
- Contents of the "importPaths" field as defined by the package recipeSTRING_IMPORT_PATHS
- Contents of the "stringImportPaths" field as defined by the package recipeDC
- Compiler binary name (e.g. "../dmd" or "ldc2")DC_BASE
- Canonical name of the compiler (e.g. "dmd" or "ldc")D_FRONTEND_VER
- The compiler frontend version represented as a single integer, for example "2072" for DMD 2.072.2DUB_EXE
- Path to the DUB executableDUB_PLATFORM
- Name of the target platform (e.g. "windows" or "linux")DUB_ARCH
- Name of the target architecture (e.g. "x86" or "x86_64")DUB_TARGET_TYPE
- Contents of the "targetType" field as defined by the package recipeDUB_TARGET_PATH
- Contents of the "targetPath" field as defined by the package recipeDUB_TARGET_NAME
- Contents of the "targetName" field as defined by the package recipeDUB_WORKING_DIRECTORY
- Working directory in which the compiled program gets runDUB_MAIN_SOURCE_FILE
- Contents of the "mainSourceFile" field as defined by the package recipeDUB_CONFIG
- Name of the selected build configuration (e.g. "application" or "library")DUB_BUILD_TYPE
- Name of the selected build type (e.g. "debug" or "unittest")DUB_BUILD_MODE
- Name of the selected build mode (e.g. "separate" or "singleFile")DUB_BUILD_PATH
- Absolute path in which the package was compiled (defined for "postBuildCommands" only)DUB_COMBINED
- "TRUE" if the --combined flag was used, empty otherwiseDUB_RUN
- "TRUE" if the "run" command was invoked, empty otherwiseDUB_FORCE
- "TRUE" if the --force flag was used, empty otherwiseDUB_RDMD
- "TRUE" if the --rdmd flag was used, empty otherwiseDUB_TEMP_BUILD
- "TRUE" if the --temp-build flag was used, empty otherwiseDUB_PARALLEL_BUILD
- "TRUE" if the --parallel flag was used, empty otherwiseDUB_RUN_ARGS
- Contains the arguments passed to the built executable in shell compatible format
User specified environment variables
Environment variables are set by keys using the defaultEnvironments and related settings in the user settings. Additionally, with higher precedence, environments and related settings in the package recipe are loaded.
For finding the default environment variables first the system environment variables are loaded, then overridden by the user 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.
Created: September 1, 2023