无法克隆指定GitHub仓库:pybind11克隆失败致TEASER++构建受阻
问题现象
构建TEASER++的Python绑定过程中,CMake自动克隆pybind11仓库失败,重复尝试3次后抛出以下错误:
Cloning into 'pybind11-src'... error: RPC failed; HTTP 400 curl 22 The requested URL returned error: 400 fatal: error reading section header 'shallow-info' -- Had to git clone more than once: 3 times. CMake Error at pybind11-download/pmc-prefix/tmp/pmc-gitclone.cmake:31 (message): Failed to clone repository: 'https://github.com/pybind/pybind11.git'
后续触发CMake命令pybind11_add_module未找到的连锁错误。手动执行git clone https://github.com/pybind/pybind11也返回相同的HTTP 400错误,但克隆其他仓库正常,且Git已更新。
解决方案
1. 改用SSH协议克隆
HTTPS协议可能存在网络或认证层面的问题,切换为SSH协议克隆:
git clone git@github.com:pybind/pybind11.git
将克隆完成的pybind11目录重命名为pybind11-src,放到TEASER++的构建目录下(示例路径:/home/klift/dev/experiments/TEASER-plusplus/build/pybind11-src),再重新运行CMake构建。
2. 禁用浅克隆
错误提示涉及shallow-info,可能是浅克隆机制导致的问题,手动克隆时关闭浅克隆:
git clone https://github.com/pybind/pybind11.git --no-shallow-clone
若需修改CMake自动克隆的行为,可找到TEASER++中配置pybind11下载的CMake脚本,添加GIT_SHALLOW OFF参数。
3. 手动下载源码包替代克隆
直接下载pybind11的zip格式源码包,解压后将目录重命名为pybind11-src,放置到TEASER++构建目录的对应位置,再重新执行构建流程。
4. 临时取消网络代理
部分代理可能对特定仓库的HTTPS请求拦截,临时取消代理后重试:
unset HTTP_PROXY unset HTTPS_PROXY git clone https://github.com/pybind/pybind11.git
内容的提问来源于stack exchange,提问作者Arsenijs Nitijevskis
相关产品推荐
相关产品推荐

