ros安装时执行sudo rosdep init报错及rosdep update超时的解决方法(2021-04-22更新)
- 报错如下:
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.
- 解决方法一(2021-04-21尝试此方法,raw.githubusercontent.com对应的IP地址,ping的时候总是超时,使用此方法偶尔会失败,请参考解决方法二):
- cd /etc检查etc下有没有ros/rosdep/sources.list.d。如果没有手动创建ros/rosdep/sources.list.d #配置环境的xavier上没有找到ros/rosdep/sources.list.d
- sudo chmod 777 /etc #给etc文件夹赋予权限
- 手动创建ros/rosdep/sources.list.d #如下图所示:

4.打开网址:https://site.ip138.com ,输入raw.githubusercontent.com 如下图所示:
5.随便选择一个地址,我选择的是151.101.196.133
6.sudo gedit /etc/hosts ,在文档中添加:151.101.196.133 raw.githubusercontent.com 保存后。 如下图所示:

7.执行sudo rosdep init
8.rosdep update
通过上述步骤就可以解决执行sudo rosdep init失败报错的问题
- 解决方法二(rosdep update超时):
网站https://ghproxy.com/支持github的资源代理,非常好用,我们将用此代理加速rosdep对Github Raw的访问,进而解决rosdep update超时问题。通过在地址前添加https://ghproxy.com/前缀来应用代理服务。操作如下:
1. cd /usr/lib/python2.7/dist-packages/rosdep2/
- sudo gedit sources_list.py
- 311行 url="https://ghproxy.com/"+url
72行 DEFAULT_SOURCES_LIST_URL = 'https://ghproxy.com/https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/sources.list.d/20-default.list'
311行 url="https://ghproxy.com/"+url #添加位置见下图

-
sudo gedit gbpdistro_support.py
36行 FUERTE_GBPDISTRO_URL = 'https://ghproxy.com/https://raw.githubusercontent.com/ros/rosdistro/'
- sudo gedit rep3.py
39行 REP3_TARGETS_URL = 'https://ghproxy.com/https://raw.githubusercontent.com/ros/rosdistro/master/releases/targets.yaml'
2. cd /usr/lib/python2.7/dist-packages/rosdistro
- sudo gedit __init__.py
68行 DEFAULT_INDEX_URL = 'https://ghproxy.com/https://raw.githubusercontent.com/ros/rosdistro/master/index-v4.yaml'
3. cd /usr/lib/python2.7/dist-packages/rosdistro/manifest_provider
- sudo gedit github.py
68行 url = 'https://ghproxy.com/https://raw.githubusercontent.com/%s/%s/package.xml'
119行 url = 'https://ghproxy.com/https://raw.githubusercontent.com/%s/%s/%s'
通过以上步骤修改完成后,执行rosdep update,问题解决。