{
  "id": "python/pip-extra-index-url-dependency-confusion",
  "signature": "ERROR: Cannot install because of a dependency confusion: package 'internal-lib' resolved from public PyPI instead of private index",
  "signature_zh": "错误：因依赖混淆无法安装：包 'internal-lib' 从公共 PyPI 而非私有索引解析",
  "regex": "ERROR:\\ Cannot\\ install\\ because\\ of\\ a\\ dependency\\ confusion:\\ package\\ 'internal\\-lib'\\ resolved\\ from\\ public\\ PyPI\\ instead\\ of\\ private\\ index",
  "domain": "python",
  "category": "auth_error",
  "subcategory": null,
  "root_cause": "When --extra-index-url is used, pip merges candidates from all indexes and picks the highest version. A malicious public package with the same name and higher version can shadow the intended private one.",
  "root_cause_type": "generic",
  "root_cause_zh": "使用 --extra-index-url 时，pip 会合并所有索引的候选包并选择最高版本。同名的恶意公共包如果版本更高，会遮蔽预期的私有包。",
  "versions": [
    {
      "version": "3.8",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "3.9",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "3.10",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "3.11",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "3.12",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Still merges with PyPI; the public version wins if higher.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Trust does not affect resolution order.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "pip install --index-url https://private/simple 'internal-lib==1.2.3'",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.9,
      "how": "pip install --index-url https://private/simple --no-index internal-lib  # only if index has it",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.85,
      "how": "pip install -c constraints.txt --extra-index-url https://private/simple internal-lib",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": null,
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.86,
  "fix_success_rate": 0.8,
  "resolvable": "partial",
  "first_seen": "2024-10-05",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}