# 错误：命令以退出状态 255 失败：hg clone 'https://hg.example.com/package' /tmp/pip-req-build-xxxxx

- **ID:** `pip/mercurial-clone-fail`
- **领域:** pip
- **类别:** install_error
- **错误码:** `ERROR`
- **验证级别:** ai_generated
- **修复率:** 88%

## 根因

pip 无法克隆 Mercurial (hg) 仓库，因为构建依赖被指定为 hg+ 方案的 VCS URL，但未安装 Mercurial 客户端或仓库 URL 不正确。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| pip 23.2 | active | — | — |
| pip 24.0 | active | — | — |
| pip 24.1 | active | — | — |
| Mercurial 6.5 | active | — | — |
| Mercurial 6.6 | active | — | — |

## 解决方案

1. ```
   Install Mercurial client via system package manager: sudo apt-get install mercurial (Debian/Ubuntu) or brew install mercurial (macOS). Then retry pip install.
   ```
2. ```
   Use a published wheel or tarball instead of the VCS URL: pip install package --no-index --find-links https://pypi.org/simple/
   ```
3. ```
   Switch to a Git mirror if available: pip install git+https://github.com/user/package.git
   ```

## 无效尝试

- **** — Running pip install with --no-clean does not fix the missing hg client; it only preserves the partial clone directory for debugging. (95% 失败率)
- **** — Using pip install --force-reinstall does not install the Mercurial client; it only re-downloads packages without addressing the missing VCS tool. (98% 失败率)
- **** — Setting PIP_REQUIRE_VIRTUALENV=true does not bypass the hg clone issue; virtual environment activation is unrelated. (90% 失败率)
