rosdep init 错误解决方法
一、安装ROS执行以下指令时报错
sudo rosdep init
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.
二、原因
这是由于 raw.githubusercontent.com 被墙,程序无法下载相应的文件导致的。所以要确保 raw.githubusercontent.com 能够被正常访问。这个网站被墙的方式是dns污染,所以我们只要能够找到这个网站的正确 IP 就可以了。
三、解决办法
1.查询IP地址
给大家几个查询 raw.githubusercontent.com 的 IP 地址比较稳定的网站:
网站1
网站2
网站3
将 raw.githubusercontent.com 粘贴到 IP 地址查询框内,得到类似下图的结果
2.将IP地址添加进文件
终端输入命令
sudo gedit /etc/hosts
将刚才查询到的 IP 地址连同 raw.githubusercontent.com 写入文件第三行,并保存退出即可。
185.199.108.133 raw.githubusercontent.com
3.重新执行指令
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
出现此提示即表示指令执行成功