Conan 图形解释¶
$ conan graph explain -h
usage: conan graph explain [-h] [-f FORMAT] [-v [V]] [-cc CORE_CONF]
[--name NAME] [--version VERSION] [--user USER]
[--channel CHANNEL] [--requires REQUIRES]
[--tool-requires TOOL_REQUIRES] [-b BUILD]
[-r REMOTE | -nr] [-u [UPDATE]] [-pr PROFILE]
[-pr:b PROFILE_BUILD] [-pr:h PROFILE_HOST]
[-pr:a PROFILE_ALL] [-o OPTIONS]
[-o:b OPTIONS_BUILD] [-o:h OPTIONS_HOST]
[-o:a OPTIONS_ALL] [-s SETTINGS]
[-s:b SETTINGS_BUILD] [-s:h SETTINGS_HOST]
[-s:a SETTINGS_ALL] [-c CONF] [-c:b CONF_BUILD]
[-c:h CONF_HOST] [-c:a CONF_ALL] [-l LOCKFILE]
[--lockfile-partial] [--lockfile-out LOCKFILE_OUT]
[--lockfile-clean]
[--lockfile-overrides LOCKFILE_OVERRIDES]
[--check-updates] [--build-require]
[--missing [MISSING]]
[path]
Explain what is wrong with the dependency graph, like report missing binaries
closest alternatives, trying to explain why the existing binaries do not match
positional arguments:
path Path to a folder containing a recipe (conanfile.py or
conanfile.txt) or to a recipe file. e.g.,
./my_project/conanfile.txt.
options:
-h, --help show this help message and exit
-f FORMAT, --format FORMAT
Select the output format: json
-v [V] Level of detail of the output. Valid options from less
verbose to more verbose: -vquiet, -verror, -vwarning,
-vnotice, -vstatus, -v or -vverbose, -vv or -vdebug,
-vvv or -vtrace
-cc CORE_CONF, --core-conf CORE_CONF
Define core configuration, overwriting global.conf
values. E.g.: -cc core:non_interactive=True
--name NAME Provide a package name if not specified in conanfile
--version VERSION Provide a package version if not specified in
conanfile
--user USER Provide a user if not specified in conanfile
--channel CHANNEL Provide a channel if not specified in conanfile
--requires REQUIRES Directly provide requires instead of a conanfile
--tool-requires TOOL_REQUIRES
Directly provide tool-requires instead of a conanfile
-b BUILD, --build BUILD
Optional, specify which packages to build from source.
Combining multiple '--build' options on one command
line is allowed. Possible values: --build="*" Force
build from source for all packages. --build=never
Disallow build for all packages, use binary packages
or fail if a binary package is not found, it cannot be
combined with other '--build' options. --build=missing
Build packages from source whose binary package is not
found. --build=cascade Build packages from source that
have at least one dependency being built from source.
--build=[pattern] Build packages from source whose
package reference matches the pattern. The pattern
uses 'fnmatch' style wildcards. --build=~[pattern]
Excluded packages, which will not be built from the
source, whose package reference matches the pattern.
The pattern uses 'fnmatch' style wildcards.
--build=missing:[pattern] Build from source if a
compatible binary does not exist, only for packages
matching pattern.
-r REMOTE, --remote REMOTE
Look in the specified remote or remotes server
-nr, --no-remote Do not use remote, resolve exclusively in the cache
-u [UPDATE], --update [UPDATE]
Will install newer versions and/or revisions in the
local cache for the given reference name, or all
references in the graph if no argument is supplied.
When using version ranges, it will install the latest
version that satisfies the range. It will update to
the latest revision for the resolved version range.
-pr PROFILE, --profile PROFILE
Apply the specified profile. By default, or if
specifying -pr:h (--profile:host), it applies to the
host context. Use -pr:b (--profile:build) to specify
the build context, or -pr:a (--profile:all) to specify
both contexts at once
-pr:b PROFILE_BUILD, --profile:build PROFILE_BUILD
-pr:h PROFILE_HOST, --profile:host PROFILE_HOST
-pr:a PROFILE_ALL, --profile:all PROFILE_ALL
-o OPTIONS, --options OPTIONS
Apply the specified options. By default, or if
specifying -o:h (--options:host), it applies to the
host context. Use -o:b (--options:build) to specify
the build context, or -o:a (--options:all) to specify
both contexts at once. Example:
-o="pkg/*:with_qt=True"
-o:b OPTIONS_BUILD, --options:build OPTIONS_BUILD
-o:h OPTIONS_HOST, --options:host OPTIONS_HOST
-o:a OPTIONS_ALL, --options:all OPTIONS_ALL
-s SETTINGS, --settings SETTINGS
Apply the specified settings. By default, or if
specifying -s:h (--settings:host), it applies to the
host context. Use -s:b (--settings:build) to specify
the build context, or -s:a (--settings:all) to specify
both contexts at once. Example: -s="compiler=gcc"
-s:b SETTINGS_BUILD, --settings:build SETTINGS_BUILD
-s:h SETTINGS_HOST, --settings:host SETTINGS_HOST
-s:a SETTINGS_ALL, --settings:all SETTINGS_ALL
-c CONF, --conf CONF Apply the specified conf. By default, or if specifying
-c:h (--conf:host), it applies to the host context.
Use -c:b (--conf:build) to specify the build context,
or -c:a (--conf:all) to specify both contexts at once.
Example:
-c="tools.cmake.cmaketoolchain:generator=Xcode"
-c:b CONF_BUILD, --conf:build CONF_BUILD
-c:h CONF_HOST, --conf:host CONF_HOST
-c:a CONF_ALL, --conf:all CONF_ALL
-l LOCKFILE, --lockfile LOCKFILE
Path to a lockfile. Use --lockfile="" to avoid
automatic use of existing 'conan.lock' file
--lockfile-partial Do not raise an error if some dependency is not found
in lockfile
--lockfile-out LOCKFILE_OUT
Filename of the updated lockfile
--lockfile-clean Remove unused entries from the lockfile
--lockfile-overrides LOCKFILE_OVERRIDES
Overwrite lockfile overrides
--check-updates Check if there are recipe updates
--build-require Whether the provided reference is a build-require
--missing [MISSING] A pattern in the form
'pkg/version#revision:package_id#revision', e.g:
"zlib/1.2.13:*" means all binaries for zlib/1.2.13. If
revision is not specified, it is assumed latest one.
conan graph explain
命令尝试对可能在提供的配置下丢失的软件包提供更详细的解释,并显示预期二进制软件包与可用软件包之间的差异。它有助于理解请求的软件包中缺少什么,无论是不同的选项、不同的设置还是不同的依赖项。
示例:
假设我们想要安装依赖于 dep/2.0.0 的 lib/1.0.0,但我们还没有二进制文件,因为最新的 CI 运行仅为使用先前版本的 dep 的 lib/1.0.0 生成了二进制文件。当我们尝试安装引用 lib/1.0.0 时,它会提示
$ conan install --requires=lib/1.0.0
...
ERROR: Missing prebuilt package for 'lib/1.0.0'
现在我们可以尝试找到对此的解释
$ conan graph explain --requires=lib/1.0.0
requires: dep/1.Y.Z
diff
dependencies
expected: dep/2.Y.Z
existing: dep/1.Y.Z
explanation: This binary has same settings and options, but different dependencies
同样,当软件包具有不同的选项值时,它也会报告,并且输出也以 JSON 格式提供
$conan graph explain --requires=lib/1.0.0 -o lib/*:shared=True --format=json
...
{
"closest_binaries": {
"lib/1.0.0": {
"revisions": {
"dc0e384f0551386cd76dc29cc964c95e": {
"timestamp": 1692672717.68,
"packages": {
"b647c43bfefae3f830561ca202b6cfd935b56205": {
"info": {
"settings": {
"arch": "x86_64",
"build_type": "Release",
"compiler": "gcc",
"compiler.version": "11",
"os": "Linux"
},
"options": {
"shared": "False"
}
},
"diff": {
"platform": {},
"options": {
"expected": [
"shared=True"
],
"existing": [
"shared=False"
]
},
"settings": {},
"dependencies": {},
"explanation": "This binary was built with same settings but different options."
},
"remote": "conancenter"
}
}
}
}
}
}
}