Skip to content

Sync and the Lock

project-builder.json (the Manifest) says what the workspace needs, as ranges. builder sync resolves those ranges to exact versions, fetches them, and writes the result to project-builder-lock.json (the Lock), next to the Manifest. builder sync --frozen installs exactly what the Lock pins and changes nothing else.

Every output on this page comes from a run on builder v0.19.12 and @pbuilder/sdk 0.22.0. The packages are the ones from the published dialect guide, served by a local npm-compatible registry.

The sync reads the Manifest and resolves everything it declares:

  • External libraries, from externals. See External collections.
  • Published dialects, from dialects, when the entry has a registry and a range.
  • Local dialects, from dialects, when the entry has a path and a conformance file.
  • The SDK. Every library and dialect says which SDK range it needs, and the sync picks one version that satisfies the workspace and all of them.

The Manifest keys are described in the project-builder.json reference.

For each range, the sync takes the lowest version that satisfies it (rule CA-4). The workspace below declares one library at ^1.0.0 and one dialect. The registry holds @e2e-test/config 1.0.0 and 1.1.0:

project-builder.json
"externals": { "@e2e-test/config": { "registry": "npm", "range": "^1.0.0" } },
"dialects": { "@e2e-test/dialect-ini": { "registry": "npm", "range": "^1.0.0" } }
Terminal window
builder sync

The sync exits with code 0 and prints wrote project-builder-lock.json. It pins 1.0.0, not 1.1.0.

For a published dialect, the sync also runs the dialect’s conformance fixture once. For a local dialect, it runs the fixture when the Lock has no hash for the dialect or a different one. See the local dialect and published dialect guides for how to write the dialect, its fixture and the errors a failing fixture gives. A failed sync writes no Lock and leaves an existing one as it was.

The sync stores what it fetches in the builder cache (BUILDER_CACHE_DIR, or a project-builder folder under your user cache directory). It installs nothing into the workspace: there is no node_modules/@e2e-test after the run.

project-builder-lock.json
{
"lockfileVersion": 1,
"manifestInputHash": "sha256-1d2f9a76…",
"sdk": {
"version": "0.22.0",
"integrity": "sha512-Ek9B1ER4…",
"source": { "ecosystem": "npm", "registry": "http://localhost:4874" }
},
"libraries": {
"@e2e-test/config": {
"version": "1.0.0",
"integrity": "sha512-I1xCjTPP…",
"source": { "ecosystem": "npm", "registry": "http://localhost:4874" },
"requiredBy": ["."]
}
},
"dialects": {
"@e2e-test/dialect-ini": {
"version": "1.0.0",
"integrity": "sha512-uhek9MlW…",
"source": { "ecosystem": "npm", "registry": "http://localhost:4874" },
"declaredBy": ["."]
}
},
"setups": []
}
Key What it holds
manifestInputHash A hash of the Manifest inputs the sync resolved from
sdk The SDK version the sync chose, with its integrity hash and where it came from
libraries Each external library: exact version, integrity, source, and requiredBy
dialects Each published dialect: exact version, integrity, source, and declaredBy
localDialects Each local dialect: its path and conformance, a hash of its folder, a hash per file in files, and declaredBy. The key appears only when the workspace has a local dialect
setups Empty here. Lifecycle setup schematics are not run yet

requiredBy and declaredBy list who asked for the entry. In this workspace, ["."] is the Manifest itself.

Run builder sync again without touching the Manifest. It exits with code 0 and prints wrote project-builder-lock.json again, but it resolves to the same versions, does not run the fixture, and leaves the Lock byte for byte the same.

Terminal window
builder sync --frozen

--frozen installs what the Lock pins. It never resolves a range, never runs a fixture and never writes the Lock. With nothing changed, it exits with code 0 and prints installed what project-builder-lock.json pins.

This is the command for CI and for a fresh checkout. With an empty builder cache, it fetches the pinned SDK, library and dialect versions again, exits with code 0, and leaves the Lock as it was.

A Manifest edit that does not change what the sync resolves does not matter here. Setting settings.depValidation to another value left builder sync --frozen at exit code 0.

--frozen refuses to run when the Lock no longer matches the Manifest. Raise the library’s range from ^1.0.0 to ^1.1.0 and run it:

Terminal window
builder sync --frozen

It exits with code 3, and the Lock stays as it was:

✗ [CLI] the Manifest and the Lock disagree: project-builder-lock.json was resolved from other Manifest inputs
sync_lock_drift
Fix: run 'builder sync' to resolve the Manifest and rewrite project-builder-lock.json

With --output=json, the same failure is one JSON line on stdout with "code":"sync_lock_drift" and "op":"sync.frozen", which a CI script can read.

A plain builder sync resolves the new range. It changes manifestInputHash and moves the library to 1.1.0 with its new integrity hash. The old 1.0.0 stays in the builder cache. After that, builder sync --frozen exits with code 0 again.

--frozen also fails with sync_lock_drift when there is no Lock at all. The message then reads the Manifest and the Lock disagree: there is no project-builder-lock.json to install from, and the command writes no Lock.

A local dialect adds a second kind of drift. The Lock stores a hash of the dialect’s folder. After an edit to a file in it, builder sync --frozen exits with code 3, names the file, and leaves the Lock as it was:

✗ [CLI] the local dialect "cfg" changed since the Lock: the hash of its folder "dialects/cfg" differs from the one the Lock records, naming the file "dialects/cfg/index.js" as changed
sync_local_dialect_changed
Fix: run 'builder sync' to run the conformance fixture on the local dialect and rewrite project-builder-lock.json

A plain builder sync runs the fixture again and updates the Lock. The local dialect guide covers this case, including what builder execute does.

Commit project-builder-lock.json with the Manifest, in the same commit as the Manifest change that caused it. The Lock is a plain file in the workspace root, and builder init does not add it to .gitignore. The pins only help the people and the CI jobs that receive the file:

  • builder sync --frozen needs a Lock to install from, so a CI job cannot run it on a checkout that has none.
  • A Manifest change committed without its Lock makes builder sync --frozen fail with sync_lock_drift, so the next person to run it learns about the mismatch in CI.

Do not commit the builder cache. It lives outside the workspace.

Error code Exit Cause Fix
sync_lock_drift 3 builder sync --frozen after a change to what the Manifest resolves, or with no Lock Run builder sync to resolve the Manifest and rewrite the Lock
sync_local_dialect_changed 3 builder sync --frozen after a local dialect’s folder changed Run builder sync to run the fixture again and rewrite the Lock
sync_dialect_fails_fixture 3 A dialect fails its conformance fixture Fix the dialect, or narrow the range of a published one. See the published dialect errors