conan remove

$ conan remove -h
usage: conan remove [-h] [-v [V]] [-cc CORE_CONF] [-f FORMAT]
                    [--out-file OUT_FILE] [-c] [-p PACKAGE_QUERY] [-r REMOTE]
                    [-l LIST] [--lru LRU] [--dry-run]
                    [pattern]

Remove recipes or packages from local cache or a remote.

- If no remote is specified (-r), the removal will be done in the local conan cache.
- If a recipe reference is specified, it will remove the recipe and all the packages, unless -p
  is specified, in that case, only the packages matching the specified query (and not the recipe)
  will be removed.
- If a package reference is specified, it will remove only the package.

positional arguments:
  pattern               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.

options:
  -h, --help            show this help message and exit
  -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
  -f FORMAT, --format FORMAT
                        Select the output format: json
  --out-file OUT_FILE   Write the output of the command to the specified file
                        instead of stdout.
  -c, --confirm         Remove without requesting a confirmation
  -p PACKAGE_QUERY, --package-query PACKAGE_QUERY
                        Remove all packages (empty) or provide a query:
                        os=Windows AND (arch=x86 OR compiler=gcc)
  -r REMOTE, --remote REMOTE
                        Will remove from the specified remote
  -l LIST, --list LIST  Package list file
  --lru LRU             Remove recipes and binaries that have not been
                        recently used. Use a time limit like --lru=5d (days)
                        or --lru=4w (weeks), h (hours), m(minutes)
  --dry-run             Do not remove any items, only print those which would
                        be removed

conan remove 命令从本地缓存或指定的远程仓库中移除 recipe 和包。根据作为参数指定的模式,可以移除完整的包,或者仅移除二进制文件,而保留 recipe 可用。您也可以在模式的版本部分使用关键字 !latest,以避免移除特定 Conan 包的最新 recipe 或包修订版本。

使用 --dry-run 避免执行实际删除操作,而是获取将要移除的元素列表。

它有 2 种可能的互斥输入

  • conan remove <pattern> 基于模式匹配的 recipe。

  • conan remove --list=<pkglist> 将移除 pkglist json 文件中指定的工件。

还有其他命令,如 conan list (请参阅那里的模式文档 conan list)、conan uploadconan download,它们采用相同的模式。

要从本地缓存中移除 recipe 及其关联的包二进制文件

$ conan remove "*"
# Removes everything from the cache

$ conan remove "zlib/*""
# Remove all possible versions of zlib, including all recipes, revisions and packages

$ conan remove zlib/1.2.11
# Remove zlib/1.2.11, all its revisions and package binaries. Leave other zlib versions

$ conan remove "zlib/[<1.2.13]"
# Remove zlib/1.2.11 and zlib/1.2.12, all its revisions and package binaries.

$ conan remove zlib/1.2.11#latest
# Remove zlib/1.2.11, only its latest recipe revision and binaries of that revision
# Leave the other zlib/1.2.11 revisions intact

$ conan remove zlib/1.2.11#!latest
# Remove all the recipe revisions from zlib/1.2.11 but the latest one
# Leave the latest zlib/1.2.11 revision intact

$ conan remove zlib/1.2.11#<revision>
# Remove zlib/1.2.11, only its exact <revision> and binaries of that revision
# Leave the other zlib/1.2.11 revisions intact

要仅移除包二进制文件,但保留 recipe,则需要指定包含 : 分隔符的模式,即 package_id

$ conan remove "zlib/1.2.11:*"
# Removes all the zlib/1.2.11 package binaries from all the recipe revisions

$ conan remove "zlib/*:*"
# Removes all the binaries from all the recipe revisions from all zlib versions

$ conan remove "zlib/1.2.11#latest:*"
# Removes all the zlib/1.2.11 package binaries only from the latest zlib/1.2.11 recipe revision

$ conan remove "zlib/1.2.11#!latest:*"
# Removes all the zlib/1.2.11 package binaries from all the recipe revisions but the latest one

$ conan remove zlib/1.2.11:<package_id>
# Removes the package binary <package_id> from all the zlib/1.2.11 recipe revisions

$ conan remove zlib/1.2.11:#latest<package_id>#latest
# Removes only the latest package revision of the binary identified with <package_id>
# from the latest recipe revision of zlib/1.2.11
# WARNING: Recall that having more than 1 package revision is a smell and shouldn't happen
# in normal situations

请注意,您可以使用 --package-query 参数来过滤将要移除的包

$ conan remove zlib/1.2.11:* -p compiler=clang
# Removes all the zlib/1.2.11 packages built with Clang compiler

您可以根据包的 settings 和 options 查询包,包括自定义的 settings 和 options。要查询 options,您需要显式添加 options. 前缀,以便 -p options.shared=False 可以工作,但 -p shared=False 不会。

以上所有命令默认在 Conan 缓存中操作。要从服务器移除工件,请使用 -r=myremote 参数

$ conan remove zlib/1.2.11:* -r=myremote
# Removes all the zlib/1.2.11 package binaries from all the recipe revisions in
# the remote <myremote>