In Conan 2, what is a profile, and what does conan profile detect write into the default one?
answer
- a text file of configuration
- settings section only
- a guess, not a contract
- Release is the detected build type
basics
~20 sA 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.
solid answer
~40 sA Conan 2 **profile** is an INI-style file, by default `<CONAN_HOME>/profiles/default`, holding `[settings]`, `[options]`, `[conf]`, `[buildenv]`, `[runenv]`, `[tool_requires]` and a few rarer sections. Every command that builds a graph reads one host profile and one build profile; with no `-pr` both default to `default`, and if it does not exist the command tells you to run `conan profile detect`. That command inspects the machine and writes only `[settings]`: `os`, `arch`, `compiler`, `compiler.version`, `compiler.cppstd` (the compiler's own default, such as `gnu17` for apple-clang 21), `compiler.libcxx` and `build_type=Release`. It warns that the result is a guess and may change between Conan versions, and it refuses to overwrite an existing profile unless you pass `--force`. Teams therefore commit their own profiles instead of relying on detection in CI.
code
console · 12 lines$ conan profile detect
detect_api: Found apple-clang 21.0
detect_api: apple-clang>=13, using the major as version
Detected profile:
WARN: This profile is a guess of your environment, please check it.
WARN: Defaulted to cppstd='gnu17' for apple-clang.
WARN: The output of this command is not guaranteed to be stable and can change in future Conan versions.
WARN: Use your own profile files for stability.
Saving detected profile to .../profiles/default
$ conan profile detect
ERROR: Profile '.../profiles/default' already existsgo deeper
Know that a profile is a text file of settings, options and conf, and that conan profile detect creates the default one with build_type=Release.
Explain the sections, the host and build profiles, and how includes and -s, -o, -c arguments override the files.
Treat detected profiles as a laptop convenience; diagnose machine differences with conan profile show and pin CI to committed profiles.
Own the profile set as a team artefact: which targets exist, how they are distributed, and who may change a compiler version in them.
## What a profile is A **profile** is the configuration input of a Conan 2 command. It is a plain text file in INI style, stored by default under `profiles/` in the Conan home folder (`~/.conan2` unless `CONAN_HOME` says otherwise), or given by path. The Conan 2.33 profile loader accepts these sections: | Section | Holds | Example | |---|---|---| | `[settings]` | project-wide configuration validated against `settings.yml` | `compiler.version=21` | | `[options]` | values for package options | `zlib/*:shared=True` | | `[conf]` | tool and core configuration | `tools.build:jobs=8` | | `[buildenv]`, `[runenv]` | environment variables for build and run | `CC=clang` | | `[tool_requires]` | tool requirements injected into packages | `cmake/3.31.6` | | `[platform_requires]`, `[replace_requires]` and relatives | system-provided or substituted packages | rarely needed | Every command that computes a dependency graph, such as `conan install`, `conan create` or `conan graph info`, uses **two** profiles: a host profile (`-pr:h`, or plain `-pr`) for the code being built and a build profile (`-pr:b`) for tools that run during the build. With no argument, both are `default`. ## What conan profile detect writes `conan profile detect` exists so a fresh machine can run its first command. Running it on a Mac with Apple clang 21 produced exactly this: ```ini [settings] arch=armv8 build_type=Release compiler=apple-clang compiler.cppstd=gnu17 compiler.libcxx=libc++ compiler.version=21 os=Macos ``` Points worth knowing: - It writes **only** `[settings]`; options, conf and tool requirements are never detected. - `build_type` is always `Release`. - `compiler.cppstd` is the compiler's own default dialect, not the newest standard it supports, which is why it says `gnu17` here. - It prints warnings that the profile is a guess, that the output is not guaranteed stable across Conan versions, and that you should use your own profile files for stability. - It stops with `Profile ... already exists` if the file is there; `--force` overwrites and `--exist-ok` skips detection. `--name` writes a profile other than `default`. ## Composing and overriding profiles Profiles are rendered with Jinja2 before parsing, so they can read environment variables or the platform, and an `include(other)` line pulls in another profile. Several `-pr` arguments compose left to right, and command-line values such as `-s build_type=Debug`, `-o "fmt/*:shared=True"` or `-c tools.build:jobs=4` override the files. `conan profile show` prints the final host and build profiles after all of that, which is the first thing to run when a build behaves differently on two machines. ## Why teams do not rely on detection 1. **Drift.** The detected values follow whatever compiler is installed. A CI image update that bumps the compiler silently changes `compiler.version`, and with it the package IDs of every compiled dependency. 2. **Stability.** Conan itself warns that the detection output may change between Conan releases. 3. **Explicitness.** A committed profile per target, such as `linux-gcc-release` or `android-armv8`, makes the configuration reviewable and lets `conan config install` distribute it to every developer and runner. `conan profile detect` stays useful for a laptop's first run; reproducible pipelines name their profiles explicitly. ## A profile set for a real team A small game studio building for desktop and console development kits, or a firmware team with one host and two boards, typically keeps a handful of profiles in a configuration repository: - a `base` profile with shared conf such as `tools.cmake.cmaketoolchain:generator=Ninja`; - one profile per target, each starting with `include(base)` and adding its `[settings]`; - a build profile for the CI runners, passed with `-pr:b`, so tools such as code generators are built for the machine that runs them. Each developer and runner receives the same files through `conan config install`, and a change to a compiler version becomes a reviewed commit instead of a side effect of whatever compiler a machine happens to have. ## Related commands - `conan profile list` shows the profiles in the Conan home. - `conan profile path default` prints where the file lives. - `conan profile show -pr:h linux-gcc-release -s:h build_type=Debug` prints the effective result without building anything.
- What happens if you run conan install on a machine that has no default profile?Conan 2 stops and tells you to create a default profile with `conan profile detect`. Unlike Conan 1, it does not detect one silently on first use, so a CI job should either run detect deliberately or, better, pass committed profiles with `-pr:h` and `-pr:b`.
- How do you see the profile Conan will actually use after includes and -s overrides?`conan profile show` with the same `-pr`, `-s`, `-o` and `-c` arguments prints the resolved host and build profiles without computing or building a graph.
- conan profile detect also writes default options such as shared=False.
- The detected compiler.cppstd is the newest standard the compiler supports.
- conan profile detect overwrites the default profile every time it runs.
- Passing -pr myprofile also makes myprofile the build profile.
- The detected profile is stable across Conan releases, so CI can rely on it.
Assumes Conan 2.33; Conan 2 requires an explicit default profile, created once with conan profile detect.