conan profile 文件默认存放在用户主目录下的 .conan/profiles/ 子目录中,linux/macos 路径为 ~/.conan/profiles/,windows 为 c:users\.conanprofiles,实际路径可通过 conan profile path 命令精确查询。

Conan profile 文件默认存储位置
Conan 的 profile 文件默认存放在用户主目录下的 .conan/profiles/ 子目录中。具体路径取决于操作系统:
- Linux/macOS:
~/.conan/profiles/(即/home/username/.conan/profiles/或/Users/username/.conan/profiles/) - Windows:
C:Users<username>.conanprofiles</username>
这个位置由 Conan 的用户缓存根目录决定,而缓存根目录本身可通过环境变量 CONAN_USER_HOME 覆盖。如果设置了该变量,profiles 就会落在 $CONAN_USER_HOME/profiles 下。
如何确认当前 profile 实际路径
别猜,直接用命令查——这是最可靠的方式,尤其当你怀疑 profile 被重定向或环境有自定义配置时:
- 查看某个 profile 的完整路径:
conan profile path <name></name>(例如conan profile path default) - 列出所有已知 profile 名称:
conan profile list(它不显示路径,但能帮你核对 name 是否存在)
注意:conan profile path 命令在 Conan 2.x 中可用;Conan 1.x 不支持该子命令,需手动检查 .conan/profiles/ 目录。
profile 文件不是硬编码路径,而是受配置影响
Conan 本身不把 profile 锁死在固定磁盘路径。它的查找逻辑是:
- 先读取
CONAN_USER_HOME环境变量(如果设了,就以此为根) - 再拼接
/profiles/<name></name> - 若未设置
CONAN_USER_HOME,才回落到系统默认用户目录下的.conan
这意味着:你在 CI 脚本里临时指定 CONAN_USER_HOME=/tmp/conan-cache,那所有 profile 都会出现在 /tmp/conan-cache/profiles/,而不是家目录。这点在容器化构建或多人协作时容易被忽略。
profile 文件名和内容结构要点
profile 文件本身是纯文本,无扩展名(如 default、linux-gcc11),内容分区块,常见错误包括:
- 把
[settings]和[options]写反顺序(Conan 不报错但可能静默忽略) - 在
[buildenv]中漏写CC/CXX却指望交叉编译生效 - 路径含空格或中文字符(尤其 Windows 下),导致
conan install解析失败,报错类似ERROR: Invalid setting 'xxx' is not a valid 'os'(实际是 profile 读取失败后的 fallback 行为)
真正容易被忽略的是:profile 文件不参与版本控制时,团队成员各自 conan profile detect 生成的 default 可能 ABI 设置不一致(比如一个用 libstdc++,另一个用 libstdc++11),导致二进制不兼容却难以定位。











