rosdep update失败解决
一 、存在问题
在运行rosdep update频繁出现error,更新失败
其原因在于国内连接外网受限所致,从而导致rosdep update时下载问题失败,最有效直接的解决方案是可以稳定可靠的连接外网,如vpn等,或者采用下面方案进行源端更换,但是要注意rosdep update成功后是否自己版本的ros有更新。
二、解决方案1
手动下载相关rosdep update的更新文件,然后修改对应下载文件的20-default.list文件,具体步骤如下:
1.下载离线文件,文件地址为:GitHub - ros/rosdistro: This repo maintains a lists of repositories for each ROS distribution 可以使用git clone或者直接下载.zip压缩包的方式进行下载,下载到/home/your name/Downloads/目录下,其中your name为你的账户名称,或者自己指定下载目录,此注意目录为后面修改相关文件指定的目录,更新文件会从此目录获取相关包。
2.修改/home/your name/Downloads/rosdistro/rosdep/sources.list.d/20-default.list 文件,/home/your name/Downloads/为自己文件下载的路径。
原文件内容为:
# os-specific listings first
yaml https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml osx
# generic
yaml https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/base.yaml
yaml https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/python.yaml
yaml https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/ruby.yaml
gbpdistro https://raw.githubusercontent.com/ros/rosdistro/master/releases/fuerte.yaml fuerte
# newer distributions (Groovy, Hydro, ...) must not be listed anymore, they are being fetched from the rosdistro index.yaml instead
更改为:(/home/your name/Downloads/为自己文件下载路径)
# os-specific listings first
yaml https:///home/your name/Downloads/rosdep/osx-homebrew.yaml osx
# generic
yaml https:///home/your name/Downloads/rosdep/base.yaml
yaml https:///home/your name/Downloads/rosdep/python.yaml
yaml https:///home/your name/Downloads/rosdep/ruby.yaml
gbpdistro https:///home/your name/Downloads/rosdep/releases/fuerte.yaml fuerte
# newer distributions (Groovy, Hydro, ...) must not be listed anymore, they are being fetched from the rosdistro index.yaml instead
3.修改源码文件
(1)sudo vi /usr/lib/python3.7/dist-packages/rosdep2/sources_list.py 其中/usr/lib/python3.7为自己安装python的路径,根据自己版本以及安装路径更换。
原文件内容:
DEFAULT_SOURCES_LIST_URL = 'https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/sources.list.d/20-default.list'
更改为:
DEFAULT_SOURCES_LIST_URL = 'file:///home/your name/Downloads/rosdistro/rosdep/sources.list.d/20-default.list'
(2)sudo vi /usr/lib/python3.7/dist-packages/rosdep2/gbpdistro_support.py 其中/usr/lib/python3.7为自己安装python的路径,根据自己版本以及安装路径更换。
原文件内容:
FUERTE_GBPDISTRO_URL = 'https://raw.githubusercontent.com/ros/rosdistro/master/releases/fuerte.yaml'
更改为:
FUERTE_GBPDISTRO_URL = 'file:///home/your name/Downloads/rosdistro/releases/fuerte.yaml'
(3)sudo vi /usr/lib/python3.7/dist-packages/rosdep2/rep3.py 其中/usr/lib/python3.7为自己安装python的路径,根据自己版本以及安装路径更换。
REP3_TARGETS_URL =https://raw.githubusercontent.com/ros/rosdistro/master/releases/targets.yaml'
更改为:
REP3_TARGETS_URL = 'file:///home/your name/Downloads/rosdistro/releases/targets.yaml'
(4)sudo gedit /usr/lib/python3.7/dist-packages/rosdistro/__init__.py 其中/usr/lib/python3.7为自己安装python的路径,根据自己版本以及安装路径更换。
原文件内容:
DEFAULT_INDEX_URL = 'https://raw.githubusercontent.com/ros/rosdistro/master/index-v4.yaml'
DEFAULT_INDEX_URL = 'file:///home/your name/Downloads/rosdistro/index-v4.yaml'
4.执行 sudo rosdep init
若出现错误,删除20-default.list 文件,文件路径为/etc/ros/rosdep/sources.list.d/
5.最后执行rosdep update
注意自己版本的ros是否更新成功,我的版本为galactic,显示Add distro “galactic”
二、解决方案2
更换国内镜像源:修改国外镜像源raw.githubusercontent.com为国内镜像源gitee.com
1.直接修改源码文件
(1)sudo vi /usr/lib/python3.7/dist-packages/rosdep2/sources_list.py 其中/usr/lib/python3.7为自己安装python的路径,根据自己版本以及安装路径更换。
原文件内容:
DEFAULT_SOURCES_LIST_URL = 'https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/sources.list.d/20-default.list'
更改为:
DEFAULT_SOURCES_LIST_URL='https://gitee.com/ssonic/rosdistro/raw/master/rosdep/sources.list.d/20-default.list'
(2)sudo vi /usr/lib/python3.7/dist-packages/rosdep2/gbpdistro_support.py 其中/usr/lib/python3.7为自己安装python的路径,根据自己版本以及安装路径更换。
原文件内容:
FUERTE_GBPDISTRO_URL = 'https://raw.githubusercontent.com/ros/rosdistro/master/releases/fuerte.yaml'
更改为:
FUERTE_GBPDISTRO_URL = 'https://gitee.com/ssonic/rosdistro/raw/master/releases/fuerte.yaml'
(3)sudo vi /usr/lib/python3.7/dist-packages/rosdep2/rep3.py 其中/usr/lib/python3.7为自己安装python的路径,根据自己版本以及安装路径更换。
REP3_TARGETS_URL = 'https://raw.githubusercontent.com/ros/rosdistro/master/releases/targets.yaml'
更改为:
REP3_TARGETS_URL = 'https://gitee.com/ssonic/rosdistro/raw/master/releases/targets.yaml'
(4)sudo vi /usr/lib/python3.7/dist-packages/rosdistro/__init__.py 其中/usr/lib/python3.7为自己安装python的路径,根据自己版本以及安装路径更换。
原文件内容:
DEFAULT_INDEX_URL = 'https://raw.githubusercontent.com/ros/rosdistro/master/index-v4.yaml'
更改为:
DEFAULT_INDEX_URL = 'https://gitee.com/ssonic/rosdistro/raw/master/index-v4.yaml'
2.执行 sudo rosdep init
若出现错误,删除20-default.list 文件,文件路径为/etc/ros/rosdep/sources.list.d/
3.最后执行rosdep update
注意自己版本的ros是否更新成功,我的版本为galactic,显示Add distro “galactic”