skip to content

In Conan 2, what are recipe revisions and package revisions, and how can zlib/1.3 resolve to a different recipe without any version change?

level: seniorimportance: should knowfreq 32%

answer

  1. hash after the hash sign
  2. recipe files versus package contents
  3. latest revision wins by default
  4. pin with #rrev or a lockfile

basics

~20 s

A recipe revision hashes the exported recipe files, or is a git commit in scm mode; a package revision hashes a built package's contents. Re-exporting a changed recipe adds a revision under the same version, and the latest wins by default.

solid answer

~50 s

A full Conan 2 reference reads `zlib/1.3#<rrev>:<package_id>#<prev>`. The **recipe revision** (`rrev`) is computed at export: by default (`revision_mode = "hash"`) it is the hash of the exported recipe files, and with `revision_mode = "scm"` it is the git commit, refusing a dirty working tree. The **package revision** (`prev`) is the hash of the package folder's contents after `package()`. When a maintainer fixes a recipe and exports it again without changing the version, a new recipe revision appears beside the old one, and every consumer that asks for `zlib/1.3` gets the latest revision: the one with the newest timestamp in the cache, or in the first remote unless `--update` compares them all. To keep the old one, pin it as `zlib/1.3#<rrev>` in `requires` or freeze it in a lockfile. A rebuild that is not bit-for-bit reproducible likewise creates a new package revision under the same package ID.

code

console · 11 lines
console
$ conan list "zlib/1.3#*"
Local Cache
  zlib
    zlib/1.3
      revisions
        e7ac6c6c6699427bbe5a7911a920e584 (2026-10-26 17:22:07 UTC)
        b397f8d9f305bd85b2bafc1f2e5c1683 (2026-10-26 17:23:26 UTC)
$ conan graph info . --lockfile=""   # requires zlib/1.3
    zlib/1.3#b397f8d9f305bd85b2bafc1f2e5c1683 - Cache
$ conan graph info .                 # conan.lock records e7ac...
    zlib/1.3#e7ac6c6c6699427bbe5a7911a920e584 - Cache

go deeper

for a junior

Know that the part after # in a reference is a revision, and that recipes can change without a version change.

for a middle

Explain how recipe and package revisions are computed and that the latest revision is used unless pinned.

for a senior

Diagnose builds that differ despite identical versions by comparing full references, and pin revisions with lockfiles in CI.

for a principal

Decide whether revisions are hash or scm based for internal recipes, and how upstream recipe revisions are vetted before teams consume them.

## The anatomy of a reference A fully qualified Conan 2 package reference has four parts beyond the name: `zlib/1.3.1#e7ac6c6c6699427bbe5a7911a920e584:59f314b5df20c4b9d21a606926f5880f62fbb759#b60201e6...` | Part | Meaning | Computed from | |---|---|---| | `zlib/1.3.1` | name and version | the recipe or the command line | | `#e7ac...` | **recipe revision** | the exported recipe files, or a git commit | | `:59f3...` | **package ID** | settings, options, dependencies | | `#b602...` | **package revision** | the contents of the package folder | `conan list "zlib/1.3#*"` shows every recipe revision of a version, with the time it was created, and the install output prints the full reference for each dependency. ## Recipe revisions The recipe revision is calculated when a recipe is exported, by `conan export` or `conan create`: - with the default `revision_mode = "hash"`, it is the hash of the exported files, so a change of a single comment yields a new revision; - with `revision_mode = "scm"` (or `"scm_folder"`), it is the git commit of the repository; Conan refuses to export from a dirty working tree in that mode, unless the dirty files are excluded with `revision_mode_excluded` or `core.scm:excluded`. A test run showed the effect: appending one comment line to a zlib recipe and exporting `zlib/1.3` again produced a second revision, `b397f8d9...`, beside the original `e7ac6c6c...`. Nothing about the version changed. ## Package revisions The package revision is the hash of the package folder's manifest, calculated after `package()` runs. Two builds of the same recipe revision and package ID give the same package revision only if they produce identical files. Timestamps embedded in archives or debug information often make them differ, so a rebuild normally creates a new package revision under the same package ID. ## Which revision a consumer gets Revisions exist so that a fix to a recipe does not need a version bump, and they are resolved like this: 1. if the requirement names a revision, `zlib/1.3#e7ac...`, that revision is used; 2. if a lockfile is in use, the revision it records is used; 3. otherwise the **latest** revision is used: the newest in the cache if the recipe is cached, or the one from the first remote that has it, unless `--update` compares the remotes by timestamp. Package revisions follow the same rule within a package ID: the latest one wins unless something pins it. On the test run, a consumer requiring plain `zlib/1.3` resolved to the new `b397...` revision, while the same consumer with a lockfile, or with `zlib/1.3#e7ac...` in its recipe, stayed on `e7ac...`. ## Inspecting revisions The `conan list` patterns follow the reference anatomy: 1. `conan list "zlib/*"` lists versions; 2. `conan list "zlib/1.3#*"` lists every recipe revision of one version, oldest first, with timestamps; 3. `conan list "zlib/1.3#latest"` shows only the latest revision, the one an unpinned consumer of that cache gets; 4. `conan list "zlib/1.3#*:*#*"` goes down to package IDs and package revisions; 5. adding `-r <remote>` asks a remote instead of the cache, which is how you check whether a revision you depend on is still published. ## Why this matters for reproducibility - **Silent changes.** A ConanCenter or internal maintainer can publish a corrected recipe for an existing version. Unpinned consumers pick it up on their next fresh resolution, which can change compile flags, patches or dependencies with no version number moving. - **Debugging.** When two builds of "the same versions" behave differently, compare the full references with revisions, not just the versions. - **Binary reuse.** A new recipe revision can change package IDs downstream when consumers embed it: the default embed mode, `full_mode`, includes the dependency's recipe revision. - **Pinning tools.** A `#rrev` in a recipe is precise but tedious to maintain by hand; a lockfile records every revision of the graph at once, which is why it is the normal pinning tool for CI.

  • Why would a team choose revision_mode = "scm"?
    It makes the recipe revision equal to the git commit that holds the recipe, so a revision maps straight to a reviewable commit. The cost is that exports from a dirty working tree fail unless the dirty files are excluded.
  • Can two package revisions exist for the same package ID?
    Yes. Rebuilding the same recipe revision with the same settings usually produces files that differ in timestamps or debug data, so the manifest hash differs and a new package revision is stored. Consumers then get the latest package revision for that ID.

  • A recipe can only change when its version number changes.
  • The recipe revision is a hash of the built binaries.
  • Conan always uses the oldest recipe revision to stay stable.
  • Two builds with the same package ID always have the same package revision.
  • Pinning a version like zlib/1.3 also pins its recipe revision.