- 2021.12.9 更新 -
系统: Ubuntu 16.04
使用有线网, ubuntu源是阿里云镜像源.
问题描述:
按照官网教程安装 ROS kinetic 时, 在 sudo rosdep init 后进行 rosdep update 时, 频繁报错超时, 原因是连外网 raw.githubusercontent.com 总是超时失败. 这种情况在境外不会发生, 因此ROS官网里的安装教程是解决不了的.
失败尝试:
尝试以下方法均无效:
- 连手机热点
- 修改超时容限 DOWNLOAD_TIMEOUT = 10000s (原先默认15s)
- 换中科大源 \ 清华源
- 开 VPN
- 在/etc/hosts文件里加上 raw.githubusercontent.com 和 raw.github.com
- 在 /usr/lib/python2.7/dist-packages/rosdep2/sources_list.py 中顶部直接插入两行代码取消SSL验证
以上方法均无效. 每次都可以断断续续hit到部分网站, 但部分网址还会报超时错误, 无法完成全部更新.
折腾一上午,终于找到了可以解决的办法. 参考: 博客
解决方法:
- 在安装 ROS 前设置 key 时就用国内的镜像,而不要用官网上 set up key 的命令 (因为它要用到外网raw.githubusercontent.com,也会超时):
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
- 使用国内 gitee 镜像里的对应文件替代 raw.githubusercontent.com (避免访问外网下载文件):
cd /usr/lib/python3/dist-packages/
sudo gedit ./rosdep2/sources_list.py
sudo gedit ./rosdep2/gbpdistro_support.py
sudo gedit ./rosdep2/rep3.py
将上述三个文件中的 “raw.githubusercontent.com/ros/rosdistro/master” 替换为 “gitee.com/ssonic/rosdistro/raw/master”
- 如果之前已经运行过 sudo rosdep init, 则删除旧的 sources.list.d/20-default.list
sudo rm /etc/ros/rosdep/sources.list.d/20-default.list
- 进行 rosdep 的初始化和更新
sudo rosdep init
rosdep update
终于可以顺利更新完, 终端显示:
reading in sources list data from /etc/ros/rosdep/sources.list.d
Warning: running ‘rosdep update’ as root is not recommended.
You should run ‘sudo rosdep fix-permissions’ and invoke ‘rosdep update’ again without sudo.
Hit https://gitee.com/ssonic/rosdistro/raw/master/rosdep/osx-homebrew.yaml
Hit https://gitee.com/ssonic/rosdistro/raw/master/rosdep/base.yaml
Hit https://gitee.com/ssonic/rosdistro/raw/master/rosdep/python.yaml
Hit https://gitee.com/ssonic/rosdistro/raw/master/rosdep/ruby.yaml
Hit https://gitee.com/ssonic/rosdistro/raw/master/releases/fuerte.yaml
Query rosdistro index https://raw.githubusercontent.com/ros/rosdistro/master/index-v4.yaml
Skip end-of-life distro “ardent”
Skip end-of-life distro “bouncy”
Skip end-of-life distro “crystal”
Skip end-of-life distro “dashing”
Skip end-of-life distro “eloquent”
Add distro “foxy”
Add distro “galactic”
Skip end-of-life distro “groovy”
Skip end-of-life distro “hydro”
Skip end-of-life distro “indigo”
Skip end-of-life distro “jade”
Skip end-of-life distro “kinetic”
Skip end-of-life distro “lunar”
Add distro “melodic”
Add distro “noetic”
Add distro “rolling”
updated cache in /home/likeyu/.ros/rosdep/sources.cache