sudo rosdep init 和 rosdep update错误的终极解决方法

sudo rosdep init 和 rosdep update错误的终极解决方法(ROS Kinetic Ubuntu16.04)

1.前言

首先介绍一下这两个命令的目的:
sudo rosdep init的目的是为了在/etc目录下新建/ros/rosdep/sources.list.d/20-default.list文件。
rosdep update 的目的是在/etc/ros/rosdep/source.list.d下放5个文件,分别是base.yaml,gentoo.yaml,osx-homebrew.yaml,python.yaml,ruby.yaml.

2.前期准备(选择镜像源)

系统设置–》软件和更新–》Ubuntu软件全部勾选上–》下载自–》其他站点–》选择最佳服务器

修改完软件源后,更新软件列表和软件( 附其他换源方法

sudo apt update
sudo apt upgrade

在这里插入图片描述

3. 解决 sudo rosdep init 问题

  1. 常见报错信息:
ERROR: cannot download default sources list from:
https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/sources.list.d/20-default.list
Website may be down.
  1. 原因: 由于raw.githubusercontent.com被墙,程序无法下载相应的文件。解决方法就是使raw.githubusercontent.com能够被正常访问。这个网站被墙的方式是dns污染,所以我们只要能够找到这个网站的正确ip就可以了 参考这个了。

  2. 解决方法
    方法1:修改hosts文件(重装一次系统后这个方法不太适用了,不建议该方法)

sudo gedit /etc/hosts

把下面这些地址拷贝到hosts文件末尾,然后保存。

192.30.253.118 gist.github.com
185.199.110.153 github.io
151.101.113.194 github.global.ssl.fastly.net
52.216.227.168 github-cloud.s3.amazonaws.com
52.74.223.119 github.com
199.232.28.133 avatars1.githubusercontent.com
199.232.28.133 avatars2.githubusercontent.com
199.232.28.133 avatars0.githubusercontent.com
199.232.28.133 avatars3.githubusercontent.com
199.232.28.133 raw.githubusercontent.com
199.232.28.133 user-images.githubusercontent.com
199.232.28.133 avatars.githubusercontent.com
199.232.28.133 github.map.fastly.net
199.232.28.133 avatars7.githubusercontent.com
54.239.31.69 aws.amazon.com
54.239.30.25 console.aws.amazon.com
54.239.96.90 ap-northeast-1.console.aws.amazon.com
54.240.226.81 ap-southeast-1.console.aws.amazon.com
54.240.193.125 ap-southeast-2.console.aws.amazon.com
54.239.54.102 eu-central-1.console.aws.amazon.com
177.72.244.194 sa-east-1.console.aws.amazon.com
176.32.114.59 eu-west-1.console.aws.amazon.com
54.239.31.128 us-west-1.console.aws.amazon.com
54.240.254.230 us-west-2.console.aws.amazon.com
54.239.38.102 s3-console-us-standard.console.aws.amazon.com
54.231.49.3 s3.amazonaws.com
52.219.0.4 s3-ap-northeast-1.amazonaws.com
54.231.242.170 s3-ap-southeast-1.amazonaws.com
54.231.251.21 s3-ap-southeast-2.amazonaws.com
54.231.193.37 s3-eu-central-1.amazonaws.com
52.218.16.140 s3-eu-west-1.amazonaws.com
52.92.72.2 s3-sa-east-1.amazonaws.com
54.231.236.6 s3-us-west-1.amazonaws.com
54.231.168.160 s3-us-west-2.amazonaws.com
52.216.80.48 github-cloud.s3.amazonaws.com
54.231.40.3 github-com.s3.amazonaws.com
52.216.20.171 github-production-release-asset-2e65be.s3.amazonaws.com
52.216.228.168 github-production-user-asset-6210df.s3.amazonaws.com

再干一件事,执行sudo gedit /etc/resolv.conf,将原有的nameserver这一行注释,并添加以下两行:

nameserver 8.8.8.8 #google域名服务器
nameserver 8.8.4.4 #google域名服务器

再次执行sudo rosdep init,这次会报一个问题,就是文件已存在:

ERROR: default sources list file already exists: /etc/ros/rosdep/sources.list.d/20-default.list
Please delete if you wish to re-initialize

这时候直接删除这个文件sudo rm /etc/ros/rosdep/sources.list.d/20-default.list,再次执行sudo rosdep init,我至今操作过很多次,没有出现不成功的状态,如果实在不成功,试试换手机热点,多执行几次,最后输出如下信息就OK了:

wrote /etc/ros/rosdep/sources.list.d/20-default.list
Recommended: please run
rosdep update

方法2:手动创建相关文件
此解决方案的原理是基于手动完成sudo rosdep init的步骤,然后再通过rosdep update完成整个方案的实施。
步骤一:首先打开一个终端,执行以下指令创建root并切换至root用户

sudo passwd    //接着提示输入UNIX密码,输入你的用户密码即可
sudo su //或者su root 然后输入密码切换至root用户
sudo mkdir -p /etc/ros/rosdep/sources.list.d
cd /etc/ros/rosdep/sources.list.d
sudo gedit 20-default.list

步骤二:将以下内容复制进20-default.list文件中

# 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

步骤三:执行以下指令

exit //退出root用户
rosdep update

4. 解决 rosdep update 问题

  1. 常见报错信息就是各种The read operation timed out.
  2. 解决,直接从对应网址保存所有需要的文件到/etc/ros/rosdep:下载链接。其中source.list.d文件是已经新建的,直接把其他文件下载然后放到对应的目录下就行。
    在这里插入图片描述
  3. 再次执行rosdep update命令,出现下面的结果,相信这次你没有苦苦等待:在这里插入图片描述
  4. 个人感觉就是网络问题,可以学着科学上网解决,懂得都懂。
  • 5
    点赞
  • 52
    收藏
    觉得还不错? 一键收藏
  • 5
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值