解决 rosdep 无法初始化问题

发布时间 2023-10-26 22:06:38作者: 滑稽果

最好你的电脑可以走代理

在执行以下命令时:

sudo rosdep init
rosdep update

会报错:

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.

这是因为 GitHub 有时候会被国内网络“封锁”,所以采取手动创建的方式进行解决。

先确保你能够代理访问,然后打开链接:https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/sources.list.d/20-default.list

img

在本地新建文件:

sudo mkdir -p /etc/ros/rosdep/sources.list.d
cd /etc/ros/rosdep/sources.list.d
sudo gedit 20-default.list

将上面打开网页中的内容复制粘贴到新建打开的文档中,并将所有 http://raw.githubusercontent.com 改为 http://raw.github.com,得到如下最终文档:

# os-specific listings first
yaml https://raw.github.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml osx

# generic
yaml https://raw.github.com/ros/rosdistro/master/rosdep/base.yaml
yaml https://raw.github.com/ros/rosdistro/master/rosdep/python.yaml
yaml https://raw.github.com/ros/rosdistro/master/rosdep/ruby.yaml
gbpdistro https://raw.github.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

保存文件,打开终端,重新运行如下指令,一般能成功完成 rosdep 初始化:

rosdep update

如果仍旧无法完成初始化,说明 GitHub 的域名被污染,无法访问。因此需要在配置文件里更改解析地址。

sudo gedit /etc/hosts

在文件最后添加:

151.101.84.133  raw.githubusercontent.com

保存文件后退出重试:

rosdep update