ROS rosdep init/update报错解决方法
在安装ROS的过程中,很多同学在执行上述指令时会提示以下错误:
ERROR: cannot download default sources list from:https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/sources.list.d/20-default.listWebsite may be down.
通常的解决办法是用手机热点
或者查询
https://raw.githubusercontent.com的实际IP地址,但是也有可能会失效。
本文会提供解决ROS rosdep init/update报错的方法。
步骤:
第一步
将 rosdistro 下载到本地
git clone https://github.com/ros/rosdistro.git
如果失败了,可以尝试
git clone https://gitee.com/wybros/rosdistro.git
第二步
进入到 sources.list.d 文件夹,
修改 gedit 20-default.list
注意:XXXX为你的用户名
cd /home/XXXX/rosdistro/rosdep/sources.list.d/
sudo gedit 20-default.list
将里面所有的 raw.githubusercontent.com 地址,
替换成本机 rosdistro 的地址。
修改前:
# 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
修改后:
*注意:*XXXX为你的用户名
# os-specific listings first
yaml file:///home/XXXX/rosdistro/rosdep/osx-homebrew.yaml osx
# generic
yaml file:///home/XXXX/rosdistro/rosdep/base.yaml
yaml file:///home/XXXX/rosdistro/rosdep/python.yaml
yaml file:///home/XXXX/rosdistro/rosdep/ruby.yaml
gbpdistro file:///home/XXXX/rosdistro/releases/fuerte.yaml fuerte
# newer distributions (Groovy, Hydro, ...) must not be listed anymore, they are being fetched from the rosdistro index.yaml instead
第三步
进入到 rosdep2 文件夹,
修改 gbpdistro_support.py
cd /usr/lib/python2.7/dist-packages/rosdep2/
sudo gedit gbpdistro_support.py
替换成自己的地址,修改后如下
***注意:*XXXX为你的用户名
FUERTE_GBPDISTRO_URL = 'file:///home/XXXX/rosdistro/releases/fuerte.yaml'
第四步
进入到 rosdep2 文件夹,
修改 rep3.py
cd /usr/lib/python2.7/dist-packages/rosdep2/
sudo gedit rep3.py
替换成自己的地址,修改后如下
***注意:*XXXX为你的用户名
REP3_TARGETS_URL = 'file:///home/XXXX/rosdistro/releases/targets.yaml'
第五步
进入到 rosdistro 文件夹
修改 init.py
cd /usr/lib/python2.7/dist-packages/rosdistro/
sudo gedit __init__.py
替换成自己的地址,修改后如下
***注意:*XXXX为你的用户名
DEFAULT_INDEX_URL = 'file:///home/XXXX/rosdistro/index-v4.yaml'
第六步
切换到root用户
sudo su
新建 sources.list.d 文件夹
sudo mkdir -p /etc/ros/rosdep/sources.list.d
进入到 sources.list.d 文件夹
修改 20-default.list
cd /etc/ros/rosdep/sources.list.d
sudo gedit 20-default.list
将以下的内容复制进 20-default.list 中
*注意:XXXX为你的用户名*
#os-specific listings first
yaml file:///home/XXXX/rosdistro/rosdep/osx-homebrew.yaml osx
#generic
yaml file:///home/XXXX/rosdistro/rosdep/base.yaml
yaml file:///home/XXXX/rosdistro/rosdep/python.yaml
yaml file:///home/XXXX/rosdistro/rosdep/ruby.yaml
gbpdistro file:///home/XXXX/rosdistro/releases/fuerte.yaml fuerte
#newer distributions (Groovy, Hydro, ...) must not be listed anymore, they are being fetched from the rosdistro index.yaml instead
最后
打开新终端执行
rosdep update
如果出现如下提示则表示成功!
XXXX为你的用户名
reading in sources list data from /etc/ros/rosdep/sources.list.d
Hit file:///home/XXXX/rosdistro/rosdep/osx-homebrew.yaml
Hit file:///home/XXXX/rosdistro/rosdep/base.yaml
Hit file:///home/XXXX/rosdistro/rosdep/python.yaml
Hit file:///home/XXXX/rosdistro/rosdep/ruby.yaml
Hit file:///home/XXXX/rosdistro/releases/fuerte.yaml
Query rosdistro index file:///home/XXXX/rosdistro/index-v4.yaml
Skip end-of-life distro "ardent"
Add distro "bouncy"
Add distro "crystal"
Add distro "dashing"
Add distro "eloquent"
Skip end-of-life distro "groovy"
Skip end-of-life distro "hydro"
Skip end-of-life distro "indigo"
Skip end-of-life distro "jade"
Add distro "kinetic"
Skip end-of-life distro "lunar"
Add distro "melodic"
updated cache in /home/XXXX/.ros/rosdep/sources.cache
参考资料
这个文章其实基本上都是参考这个博文的,但是我改了一个小bug;
步骤四的
FUERTE_GBPDISTRO_URL = 'file:///home/XXXX/rosdistro/' \ 'releases/fuerte.yaml'
会报错,要改成:
FUERTE_GBPDISTRO_URL = 'file:///home/XXXX/rosdistro/releases/fuerte.yaml'
上文中我已经修改,放心使用 :)