skip to content

In a vcpkg.json, what does the builtin-baseline field pin, and how does it give every developer and CI agent the same library versions?

level: middleimportance: must knowfreq 45%

answer

  1. a commit, not a version number
  2. versions/baseline.json at that commit
  3. a floor for every port
  4. x-update-baseline moves it

basics

~20 s

builtin-baseline is a commit SHA of the vcpkg registry repository. vcpkg reads versions/baseline.json at that commit and uses each port's version there as its minimum, so every machine resolves the same versions whatever its local vcpkg checkout contains.

solid answer

~50 s

`builtin-baseline` holds a 40-character commit SHA from the vcpkg registry repository. At that commit, `versions/baseline.json` records one version per port, and once the baseline is set every port in the dependency graph receives that version as an implicit minimum. vcpkg picks the lowest version satisfying all constraints, so unless something raises it, the baseline's version is what gets installed. Because the SHA is committed with the source, a developer whose vcpkg clone is a year newer than CI's still gets the same libraries; the versions are fetched from the registry's git history, not from the local `ports` folder. The field is shorthand for a default registry of kind `builtin` with that baseline. Without it, and with no registries configured, vcpkg ignores versioning and builds whatever ports the checkout holds, and it rejects `version>=` and `overrides`. Teams move the pin deliberately with `vcpkg x-update-baseline`.

code

console · 3 lines
console
$ vcpkg x-update-baseline --add-initial-baseline
$ git diff vcpkg.json
+  "builtin-baseline": "9eec002df1cd109f8f104cd966a763daf9751489"

go deeper

for a junior

Recall that builtin-baseline is a commit SHA of the vcpkg registry and that it makes builds reproducible across machines.

for a middle

Explain the mechanism: versions/baseline.json at that commit gives each port a minimum, and vcpkg picks the lowest version meeting every constraint, so the baseline's version wins by default.

for a senior

Show the failure modes you have hit: no baseline so machines drift, version>= rejected without one, shallow clones in CI, and a baseline set twice across vcpkg.json and vcpkg-configuration.json.

for a principal

Own the upgrade cadence: who bumps the baseline, how often, and what test run gates the bump, since one commit moves every library at once.

## What the field holds `builtin-baseline` is a top-level field of a project's `vcpkg.json`. Its value is a **40-character git commit SHA** in the vcpkg registry repository (the curated registry). The vcpkg-tool validates the format and reports that the top-level builtin-baseline "was not a valid commit sha: expected 40 hexadecimal characters" when it is not. At any commit of that repository, the file `versions/baseline.json` maps every port to one version and port-version. For example, at the commit of the 2026.10.16 registry release, `fmt` is `12.2.0` port-version 1 and `zlib` is `1.3.2` port-version 2. The versions database beside it (`versions/f-/fmt.json` and so on) lists every version a port has ever had, each with the **git tree** that holds its port files. ## How vcpkg uses it during resolution When a top-level manifest has a baseline, vcpkg runs its versioned resolver: - every port added to the dependency graph also receives a **baseline constraint**: its version at the baseline commit acts as a minimum; - declared `version>=` constraints and transitive ones from dependencies' manifests are added on top; - vcpkg then picks, per port, the **lowest version that satisfies every constraint**. With no `version>=` above the baseline, the baseline's version is exactly what gets installed. That is the reproducibility mechanism: the inputs are the manifest and a fixed commit, so a laptop with a newer vcpkg clone and a CI agent with an older one compute the same answer. vcpkg checks out each selected version's port files from git history by their tree hash, rather than taking whatever the local `ports` directory currently holds. The field has the same meaning as declaring the default registry explicitly in `vcpkg-configuration.json`: ```json { "default-registry": { "kind": "builtin", "baseline": "<sha>" } } ``` If a project sets both, vcpkg warns that it is "attempting to set builtin-baseline in vcpkg.json while overriding the default-registry in vcpkg-configuration.json" and uses the configuration file's default registry. ## What happens without it | Manifest state | Result | |---|---| | No baseline, no registries, no constraints | versioning is ignored; ports come from the local checkout | | No baseline, but `version>=` used | rejected: add a `builtin-baseline` or remove the constraint | | No baseline, but `overrides` used | rejected for the same reason | | Baseline set | versioned resolution against that commit | The no-baseline case is the trap: the build works, but two machines with different vcpkg checkouts silently build different library versions. Some read-only vcpkg installations refuse to resolve ports at all until a baseline (or a default registry) is configured. ## Moving the pin - `vcpkg x-update-baseline --add-initial-baseline` adds the field to a manifest that lacks it, using the current registry commit. - `vcpkg x-update-baseline` moves every configured registry's baseline forward: a Git registry to the newest commit of its `reference`, and the built-in registry of a cloned vcpkg to the commit that clone has checked out. `--dry-run` prints the change without writing it, and the tool lists which direct and transitive dependency versions change. - Both are `x-` commands, which vcpkg marks as experimental. Treat the bump as a dependency upgrade: one reviewed commit, a full rebuild, and a test run. ## A desktop application's workflow For a desktop application whose developers and CI agents must all build against the same libraries, the baseline turns into a small routine: - the `vcpkg.json` with its `builtin-baseline` is committed beside the code, and nobody installs libraries into a shared tree by hand; - developers' vcpkg clones may sit at different commits, as long as each is a full clone whose history holds the baseline commit; - CI installs from the same manifest, so a library change shows up in a diff of `vcpkg.json`, never as a surprise on one agent; - an upgrade is a branch that moves the baseline, rebuilds every dependency and runs the tests, and it merges only when green. Because the versions are a pure function of the manifest and the commit, a binary cache keyed on them also hits far more often than one fed by drifting checkouts. ## Traps worth knowing 1. **It is a floor, not an exact pin.** A dependency's own `version>=` can raise a port above the baseline; only `overrides` forces an exact version. 2. **History is required.** vcpkg fetches old port versions from git history, so a shallow clone of the registry fails with a message telling you to retry with a full clone (`git fetch --unshallow`). 3. **Only the top level counts.** Baselines in the manifests of ports consumed as dependencies are ignored. 4. **One configuration source.** Embedding a `configuration` field in `vcpkg.json` while also keeping a `vcpkg-configuration.json` is an error; choose one.

  • Why does a vcpkg build with a baseline fail on a CI runner that cloned the registry with depth 1?
    Versions other than the checkout's current ones are retrieved by their git tree hash from the registry's history. A shallow clone lacks those objects, so vcpkg reports that it was cloned as a shallow repository and asks for a full clone. `git fetch --unshallow` in the vcpkg directory, or a full clone step, fixes it.
  • How does builtin-baseline relate to vcpkg-configuration.json?
    It is shorthand for a `default-registry` of kind `builtin` with that baseline. If `vcpkg-configuration.json` also defines `default-registry`, vcpkg warns and uses the configuration file's registry, so a project should set the baseline in one place only.
  • Can the baseline make vcpkg install an older version than a dependency requires?
    No. The baseline only adds a minimum per port. If a dependency's manifest says `version>=` something newer, vcpkg selects that newer version. Going below a required version takes an entry in the top-level `overrides`.

  • builtin-baseline takes a version number such as 2026.10.16, not a commit SHA.
  • The baseline pins each port exactly, so nothing can ever be newer than it.
  • vcpkg reads the baseline's versions from the local ports folder, so the checkout must match it.
  • Without a baseline, version>= still works; vcpkg just picks the newest version.
  • Updating the vcpkg clone automatically upgrades every manifest that has a baseline.