{
  "id": "cmake/find-package-config-version-mismatch",
  "signature": "CMake Error: Found package version 1.2.3 but required version is 2.0.0 (found /usr/lib/cmake/MyPackage/MyPackageConfig.cmake)",
  "signature_zh": "CMake 错误：找到的包版本为 1.2.3，但要求的版本为 2.0.0（位于 /usr/lib/cmake/MyPackage/MyPackageConfig.cmake）",
  "regex": "CMake Error: Found package version \\d+\\.\\d+\\.\\d+ but required version is \\d+\\.\\d+\\.\\d+ \\(found .*\\)",
  "domain": "cmake",
  "category": "config_error",
  "subcategory": null,
  "root_cause": "find_package() found a package configuration file, but its version does not satisfy the version requirements specified in the call.",
  "root_cause_type": "generic",
  "root_cause_zh": "find_package() 找到了一个包配置文件，但其版本不满足调用中指定的版本要求。",
  "versions": [
    {
      "version": "cmake 3.20.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "cmake 3.21.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "cmake 3.22.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Delete the package config file and let CMake search again",
      "why_fails": "CMake will find the same file again if it's the only one; deleting it may break other projects that depend on it.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "Modify MyPackageConfigVersion.cmake to report a higher version",
      "why_fails": "Tampering with version files causes silent runtime errors due to API incompatibility; dangerous and unsupported.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Install a newer version of the package that meets the requirement. For example, on Ubuntu:\n\nsudo apt-get install mypackage=2.0.0\n\nOr build from source:\n\ngit clone https://github.com/example/mypackage.git -b v2.0.0\ncd mypackage && mkdir build && cd build\ncmake .. && sudo make install",
      "success_rate": 0.9,
      "how": "Install a newer version of the package that meets the requirement. For example, on Ubuntu:\n\nsudo apt-get install mypackage=2.0.0\n\nOr build from source:\n\ngit clone https://github.com/example/mypackage.git -b v2.0.0\ncd mypackage && mkdir build && cd build\ncmake .. && sudo make install",
      "condition": "",
      "sources": []
    },
    {
      "action": "Specify a lower version requirement in find_package if the API is backward-compatible:\n\nfind_package(MyPackage 1.2.3 REQUIRED)\n\nOr use EXACT to pin to a specific version:\n\nfind_package(MyPackage 2.0.0 EXACT REQUIRED)",
      "success_rate": 0.85,
      "how": "Specify a lower version requirement in find_package if the API is backward-compatible:\n\nfind_package(MyPackage 1.2.3 REQUIRED)\n\nOr use EXACT to pin to a specific version:\n\nfind_package(MyPackage 2.0.0 EXACT REQUIRED)",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "安装满足要求的较新版本的包。例如，在 Ubuntu 上：\n\nsudo apt-get install mypackage=2.0.0\n\n或从源码构建：\n\ngit clone https://github.com/example/mypackage.git -b v2.0.0\ncd mypackage && mkdir build && cd build\ncmake .. && sudo make install",
    "如果 API 向后兼容，可以在 find_package 中指定较低的版本要求：\n\nfind_package(MyPackage 1.2.3 REQUIRED)\n\n或使用 EXACT 固定到特定版本：\n\nfind_package(MyPackage 2.0.0 EXACT REQUIRED)"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://cmake.org/cmake/help/latest/command/find_package.html#version-selection",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.92,
  "fix_success_rate": 0.9,
  "resolvable": "true",
  "first_seen": "2023-09-05",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}