The cx Book 1.0.0
cx: a package manager and build tool for C and C++
Loading...
Searching...
No Matches
The lockfile and updates

cx.lock records exactly what a resolution used, so that every build and every machine gets the same dependencies. Commit it to version control.

# This file is generated by cx. It is not intended for manual editing.
version = 2
[[package]]
name = "fmt"
version = "11.1.4"
source = "registry+https://registry.example.com/index"
checksum = "sha256:…"
dependencies = []
[[package]]
name = "greeter"
version = "0.3.0"
source = "git+https://github.com/me/greeter?tag=v0.3.0"
commit = "1239137…"
dependencies = ["fmt"]

How cx uses it

  • Locked versions come first: when resolving, cx tries each package's locked version before anything else. If the lockfile still satisfies cx.toml, nothing changes.
  • Partial changes: if you add a dependency or tighten a requirement, only the packages that have to change are updated.
  • Change summary: cx prints what it changed:

    Locking spdlog v1.15.0
    Updating fmt v11.0.2 -> v11.1.4
    Removing oldlib v0.2.0
  • No network for locked builds: when everything is locked and cached, a build doesn't touch the network at all.

Updating

$ cx update # newest allowed versions of everything
$ cx update fmt spdlog # only these packages
$ cx update --resolution=lowest # oldest allowed versions

--resolution=lowest is useful in CI to check that the lower bounds in your requirements are real: cx update --resolution=lowest && cx test.

In CI

$ cx build --locked

--locked fails if cx.lock would change. That catches a cx.toml that was edited without updating the lockfile.

Lockfile version 1

Lockfiles from older cx versions (version = 1) are still read, and are rewritten as version 2 on the next resolution.