解决Ubuntu20.04系统中安装ROS noetic过程中rosdep update失败的问题

错误提示

  • 常见报错信息就是各种The read operation timed out.
  • 无法链接到raw.githubusercontent.com,难以完成对osx-homebrew.yaml、ruby.yaml等源文件的配置,例如:
ERROR: unable to process source [https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml]:
<urlopen error [Errno 104] Connection reset by peer> (https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml)

解决思路

先后尝试了更换热点、通过sudo gedit /etc/hosts增加github访问IP等方法都未成功,最终通过下载更新源网址对应的文件到本地电脑,将网络路径改成本地文件路径后,成功执行rosdep update。 参考网址: https://hm.ru/L4JATz


具体过程

  1. 下载配置压缩包ros_github到ubuntu系统本地的~/下载路径下,并将起解压到/etc/ros/路径内,具体命令如下:
cd /etc/ros/
sudo cp ~/下载/ros_github.zip ./
sudo unzip ros_github.zip

下载链接:https://pan.baidu.com/s/1PhTCqtvScV_XGf9ac0CcCg 提取码: w3ix


  1. 修改/usr/lib/python3/dist-packages/rosdistro/路径中__init__.py文件的DEFAULT_INDEX_URL配置为本地的index-v4.yaml路径,具体命令为:sudo gedit /usr/lib/python3/dist-packages/rosdistro/__init__.py
# zlm: DEFAULT_INDEX_URL is changed to rosdep update
#DEFAULT_INDEX_URL = 'https://raw.githubusercontent.com/ros/rosdistro/master/index-v4.yaml'
DEFAULT_INDEX_URL = 'file:///etc/ros/ros_github/index-v4.yaml'

文件中的修改截图如下:

注意:ubuntu18.04系统中ROS melodic版本的rosdep update失败错误,也可以采用本教程中的方法,但是注意noetic版本默认采用python3编译,melodic及先前的ROS版本,默认使用python2编译,因此对应上述版本ROS,此步骤中的文件路径为/usr/lib/python2.7/dist-packages/rosdistro/__init__.py


  1. 修改/etc/ros/rosdep/sources.list.d路径下20-default.list文件的更新源配置,具体命令为:sudo gedit /etc/ros/rosdep/sources.list.d/20-default.list 将之前的配置注释,复制以下文本,粘贴后保存。
# os-specific listings first
yaml file:///etc/ros/ros_github/osx-homebrew.yaml osx
# generic
yaml file:///etc/ros/ros_github/base.yaml
yaml file:///etc/ros/ros_github/python.yaml
yaml file:///etc/ros/ros_github/ruby.yaml
gbpdistro file:///etc/ros/ros_github/fuerte.yaml fuerte
# newer distributions (Groovy, Hydro, ...) must not be listed anymore, they are being fetched from the rosdistro index.yaml instead

文件20-default.list中的内容截图如下:


  1. 见证奇迹的时刻,重新执行rosdep update后,结果如下所示,说明更新成功

本文章使用limfx的vscode插件快速发布