解決方案:終極解決方案來啦!!!
首先要感謝 weixin_42817528,是他的留言讓這個在我心中一直懸而未決的問題終於有了近完美的解答!然後,就是要感謝藍鯨ROS機器人論壇的網友xiaoqiang。
爲了方便大家,現將解決方案移於此。
#打開hosts文件
sudo gedit /etc/hosts
#在文件末尾添加
151.101.84.133 raw.githubusercontent.com
#保存後退出再嘗試
好完美啊!!!
以下內容已經沒有價值了,不用往下看。但還是不捨得刪,留個足跡吧!
系統:ubuntu 16.04 + ROS kinetic
google chrome 與終端都可以xxxx
1. 問題
按照 ros/installation在ubuntu 16.04上安裝ros kinetic,在執行以下命令時
$ 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.
簡要分析:我將https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/sources.list.d/20-default.list複製到瀏覽器地址欄打開,能夠進入。開始我只能瀏覽器訪問xx,終端ping不通xx。所以,開始我認爲問題出現在終端不能xxxx上。後來,終於使終端能夠訪問谷歌,發現問題仍沒有解決。於是總結,我的問題並不是xxxx引起的。
注意後面解決方案三需要xxxx。
2. 解決
將問題放到網上搜了一下,相關的社區給出一些解決方法,可是這些方法對我無效。本篇將所有別人已經說了可行的解決方案與本人自己解決的方案都列出。該問題雖然現象一樣,但是內部原因有很多種,大家可以按照順序一個個試。希望有一個有用!
2.1 解決方案一
執行以下命令後再運行sudo rosdep init
sudo apt-get install ca-certificates
2.2 解決方案二
執行以下命令
sudo c_rehash /etc/ssl/certs
sudo -E rosdep init
2.3 解決方案三
這是我自己摸索出來的解決方法,實在不行可以一試!
首先保證你的瀏覽器可以xxxx,然後打開以下地址
https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/sources.list.d/20-default.list
打開的頁面:
在本地新建對應目錄/etc/ros/rosdep/sources.list.d
$ sudo mkdir -p /etc/ros/rosdep/sources.list.d
並定位到該目錄:
$ cd /etc/ros/rosdep/sources.list.d
新建文件20-default.list
:
sudo gedit 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
並將所有raw.githubusercontent.com
改爲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 update
得到以下信息,成功!!!
我的方式,等於人爲的將文件放置到本地對應位置,這一系列過程替代
sudo rosdep init
附加步驟:
如果經過以上過程仍不成功,更換ubuntu與ros的源:
- 更換ubuntu的源爲國內鏡像源(更換操作請點擊鏈接)。
- 更換ros的源爲國內鏡像源(執行以下命令即可)
sudo sh -c '. /etc/lsb-release && echo "deb http://mirrors.ustc.edu.cn/ros/ubuntu/ `lsb_release -cs` main" > /etc/apt/sources.list.d/ros-latest.list'
然後
sudo apt-get update
rosdep update
2.4 解決方案四:卸載重裝OLO
部分參考ubuntu16.04 運行rosdep init 返回ERROR:cannot download default sources list from:
這個問題的產生,根本問題出在源。
1)如果電腦無法xxxx,那麼在安裝ros前,老老實實地先把源改成國內鏡像源,然後再進行安裝。如果出錯,可以試試方法一或二。
2)如果可以xxxx,那麼可以不改源,但是在安裝ros過程中一直掛着xxx,然後繼續後面的安裝步驟,萬一出錯,可以試試本博客的方法三。
下面給出你可能需要的幾個命令,如果你網絡流量夠的話,我建議可以卸載重裝,多嘗試幾次;如果流量不夠,我建議還是先按照本文解決方法走一遍.等下次系統被搞廢后,重裝ros前,根據自己實際情況(有沒有xxxx),決定是不是需要將源改成國內鏡像源。下面給出卸載重裝步驟,卸載完之後,記得換源在裝ros啊!!!
.
- 1.卸載之前安裝的ros:
$ sudo apt-get remove ros-*
這一步要特別注意,確保把舊的安裝文件全部刪除了.以確保下次安裝的ros是從新源裏重新下載安裝的.一個小技巧來檢測安裝是基於舊文件還是新源的方法:安裝ros異常的快(過程中一開始就看到解析,沒有看到下載),說明舊文件沒被刪除,安裝時直接用的是舊文件.
- 2.將源更改爲國內鏡像源,如中科大的源,清華大學的源等.具體源更改可參照官網.如果沒有xx工具 ,不要傻乎乎的用下圖1.2節中的源.請點
Mirrors
進入查看國內鏡像源,並自行百度添加過程.
- 3.然後執行
$ sudo apt-get update
$ sudo apt-get install ros-kinetic-desktop-full
$ sudo rosdep init
$ rosdep update
結語
願所有認真調BUG的人都能被溫柔對待。小心心真的很脆很弱!!!