ps:下面操作是Linux系统,针对win操作系统也适合
问题现象
在运行conan install时,本地没有对应的库的缓存,conan会自动从conan center下载,可能会出现以下情况,重试多次,仍然是报错。
libssh2/1.11.0: Calling source() in /root/.conan2/p/libss767f7ba6d9ff3/s/src
libssh2/1.11.0: ERROR: Error downloading file https://github.com/libssh2/libssh2/releases/download/libssh2-1.11.0/libssh2-1.11.0.tar.xz: 'HTTPSConnectionPool(host='github.com', port=443): Max retries exceeded with url: /libssh2/libssh2/releases/download/libssh2-1.11.0/libssh2-1.11.0.tar.xz (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f2ed1abbe10>: Failed to establish a new connection: [Errno -2] Name or service not known',))'
libssh2/1.11.0: Waiting 5 seconds to retry...
libssh2/1.11.0: ERROR: Error downloading file https://github.com/libssh2/libssh2/releases/download/libssh2-1.11.0/libssh2-1.11.0.tar.xz: 'HTTPSConnectionPool(host='github.com', port=443): Max retries exceeded with url: /libssh2/libssh2/releases/download/libssh2-1.11.0/libssh2-1.11.0.tar.xz (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f2ed0b61c18>: Failed to establish a new connection: [Errno -2] Name or service not known',))'
libssh2/1.11.0: Waiting 5 seconds to retry...
ERROR: libssh2/1.11.0: Error in source() method, line 94
get(self, **self.conan_data["sources"][self.version], strip_root=True)
ConanException: Error downloading file https://github.com/libssh2/libssh2/releases/download/libssh2-1.11.0/libssh2-1.11.0.tar.xz: 'HTTPSConnectionPool(host='github.com', port=443): Max retries exceeded with url: /libssh2/libssh2/releases/download/libssh2-1.11.0/libssh2-1.11.0.tar.xz (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f2ed0b75208>: Failed to establish a new connection: [Errno -2] Name or service not known',))'
手动下载解决
1、将日志中的url复制到浏览器,https://github.com/libssh2/libssh2/releases/download/libssh2-1.11.0/libssh2-1.11.0.tar.xz,进行手动下载。(可以开代理,或者IDM多线程下载)
2、修改conanfile.py
aii@debian:~/.conan2/p/libss767f7ba6d9ff3/e$ vi conanfile.py
def source(self):
# 将下载解压操作注释了
# get(self, **self.conan_data["sources"][self.version], strip_root=True)
apply_conandata_patches(self)
3、运行一下conan install操作,这时会有报错:CMake Error: The source directory "/home/aii/.conan2/p/b/libss572bb9f56ef42/b/src" does not appear to contain CMakeLists.txt.没有关系,目的是跳过状态。删除新生产的目录rm -rf /home/aii/.conan2/p/b/libss572bb9f56ef42
4、将下载成功后,将libssh2-1.11.0.tar.xz文件解压到对应目录/root/.conan2/p/libss767f7ba6d9ff3/s/src,注意src下是libssh2-1.11.0目录下的文件
5、再次运行conan install操作,就正常了,直接编译,安装对应的库