skip to content

As a lead, how would you set a team's Conan 2 policy for pinning and updating third-party C++ packages across the main branch and release branches?

level: principalimportance: should knowfreq 30%

answer

  1. ranges for flexibility, locks for reproducibility
  2. who owns the remote
  3. scheduled, reviewed updates
  4. release branches frozen
  5. security fixes need a fast path

basics

~20 s

There is no single answer, but a common policy is: libraries declare ranges, applications commit lockfiles, CI consumes only a vetted internal remote, main refreshes its lock on a schedule through reviewed changes, and release branches stay frozen except for deliberate security updates.

solid answer

~40 s

I would separate **declaring compatibility** from **choosing exact builds**. Library recipes use ranges such as `[>=1.3 <2]` so graphs combine without conflicts, while every application and release branch commits a `conan.lock` that records versions and recipe revisions. CI resolves only from an internal remote holding vetted copies of ConanCenter recipes and binaries, with `conancenter` disabled, so an upstream revision cannot appear unannounced. On main, a scheduled job regenerates the lock with `--update` for every configuration, builds and tests, and opens a reviewed change. Release branches never refresh automatically: a security fix arrives as a targeted lock update. The trade-offs are update latency against surprise breakage, mirror upkeep against upstream exposure, and how many configurations the team commits to building.

go deeper

for a junior

Know that versions can be pinned exactly, allowed to float within a range, or frozen by a lockfile.

for a middle

Explain how ranges, recipe revisions and lockfiles interact, and why libraries and applications pin differently.

for a senior

Run the mechanics: committed locks across configurations, scheduled refresh jobs, targeted security updates and an internal remote.

for a principal

Choose and defend the trade-off between update latency, conflict frequency, mirror cost and release stability for your organisation, and define who approves changes.

## The decision Every team that consumes third-party C++ packages through Conan 2 eventually has to answer: who decides which exact version and recipe revision of zlib, fmt or OpenSSL a given build uses, and when does that change? Conan offers the mechanisms, version ranges, revisions, lockfiles, remotes, overrides, but not the policy. This is a judgment call with real costs either way. ## The forces in tension | Goal | Pushes toward | Cost | |---|---|---| | Reproducible releases | exact pins, committed lockfiles | updates become work someone must schedule | | Fewer graph conflicts | ranges in library recipes | builds drift unless locked | | Fast security fixes | easy, frequent updates | more churn and retesting | | Control over upstream changes | internal mirror of vetted recipes | mirror maintenance, slower access to new packages | | Cheap CI | prebuilt binaries on a remote | build infrastructure and storage | ## A policy many teams converge on 1. **Libraries declare ranges.** Internal library recipes use ranges such as `zlib/[>=1.3 <2]` or `fmt/[~11.0]`, so applications can combine them. Exact pins in libraries push conflicts onto every consumer and force `override` or `force` at the root. 2. **Applications and branches commit lockfiles.** Each application keeps `conan.lock` beside its conanfile; Conan 2 loads it automatically and fails on unknown requirements, so CI resolves exactly what was reviewed. The lock covers every configuration the team ships, built up with repeated `conan lock create` runs or `conan lock merge`. 3. **CI talks to one internal remote.** Vetted recipes and binaries are copied from ConanCenter into a team remote; `conancenter` is disabled or removed in CI, and remotes and profiles are distributed with `conan config install`. A new upstream recipe revision then reaches builds only when someone imports it. 4. **Main updates on a schedule.** A job, weekly for example, runs `conan lock create . --lockfile="" --update` for the first configuration and extends that file for the others, builds, runs the tests and opens a change containing the `conan.lock` diff. Reviewers see exactly which versions and revisions moved. 5. **Release branches stay frozen.** They never pick up the scheduled refresh. A security fix is a targeted `conan lock add` or `conan lock update` for that one package, rebuilt and tested, with the rest of the graph untouched. 6. **Tool versions are pinned too.** CMake, Ninja and code generators come through `tool_requires`, recorded under `build_requires` in the lock or pinned in profiles, so a new CMake cannot change a release build. ## Where reasonable teams differ - **Exact pins everywhere instead of ranges.** Simpler to read and needs no lock tooling, but every bump touches many recipes and conflicts are frequent. It suits a small graph. - **No mirror.** Consuming ConanCenter directly is cheaper to run, and a lockfile already pins recipe revisions; the risk is that a locked revision disappears or that new packages enter unreviewed through a developer's partial lock. - **Update cadence.** Weekly keeps each diff small; monthly or per-release batches reduce churn but make each update riskier and slower for security fixes. - **Revision mode for internal recipes.** `revision_mode = "scm"` ties revisions to commits and makes provenance obvious, at the price of refusing exports from dirty trees. - **Binary policy.** Locking package revisions as well is possible but rarely worth it; most teams lock recipes and let package IDs and the remote decide binaries. ## How to tell the policy is working - A release build from six months ago resolves the same references today. - A CVE in a dependency reaches main within days and a release branch within one reviewed change. - Version conflicts are settled at application roots, rarely with `force`, and never by declaration order. - Nobody needs `--lockfile-partial` or `--build="*"` in CI. The principle that holds across variants: ranges say what is compatible, lockfiles say what was tested, and only reviewed changes move a lockfile.

  • Is a lockfile enough if the team still consumes ConanCenter directly?
    It pins versions and recipe revisions, so builds are reproducible while those revisions remain available. What it cannot do is vet new packages or guarantee that a locked revision stays published; an internal mirror adds that control at the cost of maintaining it.
  • How would you handle an urgent CVE in zlib on three release branches?
    Import the fixed zlib into the internal remote, then on each branch update only that entry, for example with `conan lock add --requires=zlib/<fixed>` or `conan lock update`, rebuild, run the tests and merge each reviewed lock diff. The rest of each branch's graph stays frozen.

  • Exact pins in every library recipe are the only way to get reproducible builds.
  • Once a lockfile exists, dependencies never need updating.
  • Release branches should pick up the weekly dependency refresh automatically.
  • Disabling ConanCenter is pointless because lockfiles already pin everything.