In Conan 2, what do --build=missing, --build=never, --build="*" and a --build pattern each tell conan install to do?
answer
- default: never build, error out
- missing means after compatibility
- patterns use fnmatch wildcards
- tilde excludes a pattern
basics
~20 sWithout --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 sThe `--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$ 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=missinggo deeper
Remember that the default is strict and that --build=missing compiles only what has no binary.
Explain patterns, exclusions with a tilde, the never and cascade modes, and that compatibility is checked before missing triggers a build.
Pick different policies for consumer and package-producing pipelines, and read the Missing lines to decide between building and fixing a profile.
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.