(已解决) 境内 Ubuntu16.04 下安装 ROS kinetic 时 rosdep update 超时报错: The handshake operation timed out

本文详细记录了在境内Ubuntu 16.04环境下安装ROS kinetic时遇到的rosdep update超时问题及解决方案。通过替换国内gitee镜像源,成功解决了由于访问raw.githubusercontent.com导致的更新失败问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

- 2021.12.9 更新 -

系统: Ubuntu 16.04
使用有线网, ubuntu源是阿里云镜像源.

问题描述:

按照官网教程安装 ROS kinetic 时, 在 sudo rosdep init 后进行 rosdep update 时, 频繁报错超时, 原因是连外网 raw.githubusercontent.com 总是超时失败. 这种情况在境外不会发生, 因此ROS官网里的安装教程是解决不了的.

失败尝试:

尝试以下方法均无效:

  1. 连手机热点
  2. 修改超时容限 DOWNLOAD_TIMEOUT = 10000s (原先默认15s)
  3. 换中科大源 \ 清华源
  4. 开 VPN
  5. 在/etc/hosts文件里加上 raw.githubusercontent.com 和 raw.github.com
  6. 在 /usr/lib/python2.7/dist-packages/rosdep2/sources_list.py 中顶部直接插入两行代码取消SSL验证

以上方法均无效. 每次都可以断断续续hit到部分网站, 但部分网址还会报超时错误, 无法完成全部更新.

折腾一上午,终于找到了可以解决的办法. 参考: 博客

解决方法:
  1. 在安装 ROS 前设置 key 时就用国内的镜像,而不要用官网上 set up key 的命令 (因为它要用到外网raw.githubusercontent.com,也会超时):
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
  1. 使用国内 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

  1. 如果之前已经运行过 sudo rosdep init, 则删除旧的 sources.list.d/20-default.list
sudo rm /etc/ros/rosdep/sources.list.d/20-default.list
  1. 进行 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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值