Skip to main content

Dependencies

Formats

The [dependencies] section supports three formats:

String (registry)

[dependencies]
fmt = "10.1.1"
spdlog = "1.12"
catch2 = "3.4.0"

The version string is used as-is for registry lookup.

Table (git)

[dependencies]
fmt = { git = "https://github.com/fmtlib/fmt", tag = "10.1.1" }

Fields: git, branch, tag, rev.

Table (path)

[dependencies]
mylib = { path = "../mylib" }

Registry

DCR uses a package registry for dependency lookup by name.

# ~/.dcr/config.toml
[[registry]]
name = "default"
url = "https://index.dcr.pm"

Registry priority: order in config.toml. The DCR_INDEX_PATH variable overrides the path to index.json.

Git dependencies

DCR clones git repositories via git2:

  • branch — switch to a branch
  • tag — switch to a tag
  • rev — switch to a specific commit
  • features — feature flags (parsed, but does not affect build)

Cache path: ~/.dcr/git/<hash>/.

Path dependencies

Local paths. DCR automatically discovers include and lib directories from the neighbor's dcr.toml.

[dependencies]
mylib = { path = "/abs/path/to/lib" }
mylib = { path = "../relative/path" }

dcr.lock

Dependency lock file. Contains package names and sources.

Created during dcr build when registry dependencies are present. Not updated during dcr add — only on the next dcr build.

Resolution process

  1. Load all dependencies (registry → git → path)
  2. For path deps: recursively read their dcr.toml
  3. For registry deps: search index.json
  4. For git deps: clone to cache
  5. Collect include_dirs, lib_dirs, libs for the compiler