skip to content

Profiles and Binaries

A profile states compiler, standard, build type and architecture, and those settings hash into a package ID. Interviewers ask why a binary was rebuilt and what --build=missing does.

on this pageshow

explore

questions

5

In Conan 2, what do --build=missing, --build=never, --build="*" and a --build pattern each tell conan install to do?

level: middleimportance: must knowfreq 55%

answer

  1. default: never build, error out
  2. missing means after compatibility
  3. patterns use fnmatch wildcards
  4. tilde excludes a pattern

basics

~20 s

Without --build, conan install never compiles a dependency and fails on a missing binary. --build=missing builds only packages with no usable binary, --build="*" rebuilds everything, a pattern rebuilds matching packages, and --build=never forbids building outright.

solid answer

~40 s

The `--build` argument decides which packages may be built from source. With no `--build`, `conan install` uses existing binaries and stops with `Missing prebuilt package` if one is absent. `--build=missing` builds exactly the packages for which no binary was found, after the compatibility rules had their chance. `--build=missing:<pattern>` limits that to matching packages. `--build=<pattern>`, using fnmatch wildcards such as `--build="fmt/*"`, rebuilds matching packages even when binaries exist, and `--build="*"` rebuilds everything. `--build=~<pattern>` excludes packages from those forced builds but not from `missing`, for which the form is `--build=missing:~<pattern>`; `--build=cascade` rebuilds anything with a dependency being built, which Conan itself warns is inefficient, and `--build=never` forbids any build and cannot be combined with other values. Several `--build` arguments can be combined, and `conan create` builds the created package even without one.

code

console · 9 lines
console
$ conan install . -s compiler.version=17
fmt/11.0.2: Checking 13 compatible configurations
fmt/11.0.2: No compatible configuration found
    fmt/11.0.2#f84e...:461f1201... - Missing
ERROR: Missing prebuilt package for 'fmt/11.0.2'. You can try:
    - List all available packages using 'conan list "fmt/11.0.2:*" -r=remote'
    - Explain missing binaries: replace 'conan install ...' with 'conan graph explain ...'
    - Try to build locally from sources using the '--build=fmt/11.0.2' argument
$ conan install . -s compiler.version=17 --build=missing

go deeper

for a junior

Remember that the default is strict and that --build=missing compiles only what has no binary.

for a middle

Explain patterns, exclusions with a tilde, the never and cascade modes, and that compatibility is checked before missing triggers a build.

for a senior

Pick different policies for consumer and package-producing pipelines, and read the Missing lines to decide between building and fixing a profile.

for a principal

Set the organisation's rule for who may build from source in CI and how new binaries reach the shared remote.

## What the policy controls After Conan 2 has resolved the graph and computed a **package_id** for every node, each node needs a binary. The `--build` argument, available on `conan install`, `conan create`, `conan graph info` and other graph commands, decides which nodes may be **compiled from source** instead of reused from the cache or a remote. ## The values | Argument | Builds from source | |---|---| | *(none)* | nothing; a missing binary is an error | | `--build=missing` | every package with no usable binary | | `--build=missing:<pattern>` | packages with no usable binary that match the pattern | | `--build=<pattern>` | every package matching, even if a binary exists | | `--build="*"` | everything in the graph | | `--build=~<pattern>` | excludes matching packages from forced builds (patterns, `*`, `cascade`), not from `missing` | | `--build=missing:~<pattern>` | packages with no usable binary, except those matching | | `--build=cascade` | packages with at least one dependency being built | | `--build=never` | nothing, even where another rule would; cannot be combined | | `--build=compatible:<pattern>` | experimental: builds the closest compatible configuration when the requested one is invalid | Patterns use **fnmatch** wildcards and match package references, so `--build="zlib/*"` matches any zlib version. Several `--build` arguments combine, for example `--build=missing --build="mathcore/*"`. ## The default: no --build Without the argument, `conan install` is strict. On a missing binary it prints the configuration it was looking for and stops, suggesting to list available packages, to run `conan graph explain`, or to build that reference with `--build=<ref>`. This default protects a pipeline from silently spending an hour compiling a toolchain because one setting changed. ## --build=missing and compatibility `--build=missing` is applied **after** the compatibility rules. When the exact package ID is absent, Conan first checks the compatible configurations that the `compatibility.py` plugin and the recipe's `compatibility()` method offer; by default that covers other `compiler.cppstd` values. On a test run with a gnu17 binary in the cache, `-s compiler.cppstd=20` printed `Found compatible package ... compiler.cppstd=gnu17` and nothing was built. Only when no compatible binary exists does `missing` build the package. That makes `--build=missing` safe to leave on for developers, and expensive in CI when an unexpected change makes everything "missing". ## Forced rebuilds and exclusions - `--build="fmt/*"` rebuilds fmt even if a binary exists, useful after a suspected corrupt or wrongly built binary. - `--build="*"` rebuilds the whole graph, including large dependencies; it is rarely the right default. - `--build="*" --build=~"llvm/*"` rebuilds everything except one heavy package. - `--build=missing:~"llvm/*"` builds what is missing except that package, which then fails loudly so someone uploads it. Writing `--build=missing --build=~"llvm/*"` instead does **not** protect it: on a test run Conan printed `Excluded build from source` and still built the missing package, because `~` only filters forced builds. - `--build=cascade` rebuilds consumers of anything being rebuilt; Conan prints a warning that it is generally inefficient, because the package ID modes already decide which consumers need new binaries. ## Recipes and create - `conan create` without `--build` builds the package being created and treats its dependencies as an install would. - A recipe can set `build_policy = "missing"` so that its binary is built when absent even without the flag, or `"never"` for packages only produced with `conan export-pkg`. ## Choosing a policy for CI 1. **Consumer pipelines** that should only use what the team's remote already has: no `--build`, so a missing binary fails fast and points at the gap. 2. **Package-producing pipelines** that fill the remote: `--build=missing`, followed by `conan upload` of the new binaries. 3. **Investigations**: a targeted `--build="pkg/*"` for the one package under suspicion, never `--build="*"` as a habit. Which settings change make binaries go missing in the first place is a question of profiles and package IDs.

  • Does --build=missing rebuild a package whose cppstd differs from the profile?
    Not by default. The compatibility plugin first offers other `compiler.cppstd` values, and if a compatible binary exists Conan uses it. Only when no compatible binary exists is the package built.
  • Why is --build=never not combinable with --build=missing?
    They contradict each other: never forbids every build, missing allows some. Conan 2 rejects the combination with an error instead of guessing which one you meant.

  • Without --build, conan install compiles whatever binaries are missing.
  • --build=missing rebuilds every package whose binary is older than its recipe.
  • --build=cascade is the efficient way to keep consumers consistent.
  • --build="*" only builds packages that are missing.
  • --build=missing ignores compatible binaries and always builds the exact configuration.
  • Adding --build=~pkg/* to --build=missing stops pkg from being built when its binary is missing.
open as a page

In Conan 2, how do settings, options and conf differ, and which of them change a package's package_id?

level: middleimportance: must knowfreq 58%

basics

~20 s

Settings are project-wide values such as compiler and build_type; options are per-package switches such as shared; conf configures Conan and its tools. Settings and options a recipe declares enter its package_id, while conf stays out unless tools.info.package_id:confs lists it.

open as a page

In Conan 2, what is a profile, and what does conan profile detect write into the default one?

level: juniorimportance: should knowfreq 55%

basics

~20 s

A profile is a text file of sections such as [settings], [options], [conf] and [tool_requires] that configures a Conan 2 command. conan profile detect guesses only [settings]: os, arch, compiler, compiler.version, compiler.cppstd, compiler.libcxx and build_type=Release.

open as a page

In Conan 2, in what order does conan install look in the local cache and the configured remotes for a recipe and its binaries?

level: middleimportance: should knowfreq 40%

basics

~20 s

Conan 2 looks in the local cache first and uses what it finds without contacting remotes. Otherwise it queries remotes in the order conan remote list shows and takes the first hit; --update checks all remotes for newer revisions.

open as a page

After a developer bumps compiler.version in the shared Conan 2 CI profile, every compiled dependency rebuilds from source. Why, and how do you confirm and contain it?

level: seniorimportance: should knowfreq 45%

basics

~20 s

compiler.version is a setting, so every compiled package gets a new package_id with no binary on the remote, and --build=missing builds them all. conan graph explain shows the diff; contain it by prebuilding and uploading once, or by an explicit compatibility rule.

open as a page