1. Introduction
Regarding the problems encountered sudo rosdep init
and rosdep update
failures during the ROS installation process , the posts on the Internet are simply a big basket. I recently installed ROS again, and found that the previously recorded solutions are no longer effective. I searched all the posts on the Internet, and 99% of them were reprinted or outdated. Finally I found an article that made it clear, you can refer to this article: The ultimate solution to ROS rosdep init/update error reporting .
So remind everyone, sometimes you need to look at the latest posts. . The most read are not necessarily better than the latest ones. So it’s 2021, and the party has been founded 100 years ago. It’s enough for everyone to read my article hahaha~~~
2. Reasons for failure
To solve the problem, first figure out the cause of the problem. sudo rosdep init
And rosdep update
the root cause can not afford to run a "raw.githubusercontent.com" This site does not help .
"raw.githubusercontent.com" is actually the user server of Google GitHub, sudo rosdep init
and rosdep update
some files are downloaded from this website. When ROS is installed for the first time, it is generally inaccessible to the domestic network.
Three. Solution
Since it is a network problem, it is enough to solve the network problem. (If you want to see the ultimate solution, skip to method three)
(1) Method 1
Go online scientifically. I won’t say more about it. If you can find a way to go online, nothing will happen. In view of the fact that most comrades do not have this condition, this method is not advocated. (Many posts say that using a mobile phone to open hotspots, the mobile hotspots I have been using proved to be useless)
(Two) method two
sudo rosdep init
In fact, to do is to download a 20-default.list
file to a /etc/ros/rosdep/sources.list.d
folder, you can create this file manually and then paste the content, create a file:
sudo gedit /etc/ros/rosdep/sources.list.d/20-default.list
Then paste the following content into it:
# 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
This completes the sudo rosdep init
work. The final 20-default.list
content as shown in the figure
rosdep update
is 20-default.list
to download the corresponding file according to the URL link in the above file. You can see that five files osx-homebrew.yawl,base.yawl,python.yawl,ruby.yawl,fuerte.yawl
are used, and the addresses are "raw.githubusercontent.com"
below, because the network If you can't get in, of course, rosdep update
if you can't download it, you won't be able to run it.
Since the default IP is not accessible to this website, you can find an alternative IP "raw.githubusercontent.com"
by going to the IP address of the IP query network (https://site.ip138.com) and click to enter . The query result is like this (the result is not fixed ):
You can see that there are four IP addresses available, 185.199.108.133-185.199.111.133, the address is Dutch, don't care about this. Try to ping these ips:
ping 185.199.108.133
The result is as follows, indicating that the connection is normal, and the shorter the time behind, the faster the network transmission speed. You can try all four IPs and choose the fastest one. Take 185.199.108.133 as an example here.
Terminal input command:
sudo gedit /etc/hosts
Add a row
185.199.108.133 raw.githubusercontent.com
/etc/hosts finally looks like this:
(Many blogs also talked about this method, telling you to directly add "152.XXX.XXX.XXX raw.githubusercontent.com", or other IP addresses, but these IP addresses are out of date because it will be updated, of course. Used. So be sure to check this IP query website by yourself)
Okay, you can visit now. Re-execute it rosdep update
. If it goes well, you can succeed. This method is very easy to use as of 2020, and it can be regarded as the ultimate solution.
But this year may be unfavorable, and this year will not work well.
The basic errors reported are network timeouts, and handshake timeout may be prompted during the download of any of the above five files.
ERROR: unable to process source [http://github.com/ros/rosdistro/raw/master/rosdep/base.yaml]:
<urlopen error _ssl.c:489: The handshake operation timed out> (http://github.com/ros/rosdistro/raw/master/rosdep/base.yaml)
Okay, many people have encountered this problem, and many posts teach us to modify the timeout period. The method is to change the values /usr/lib/python2.7/dist-packages/rosdep2/
in the three files sources_list.py、gbpdistro_support.py、rep3.py
below, DOWNLOAD_TIMEOUT = 15.0
and change them to a larger value.
sudo gedit /usr/lib/python2.7/dist-packages/rosdep2/sources_list.py
Ctrl+ FSearch DOWNLOAD_TIMEOUT
, change the next 15 to a larger value, such as 100. Modify several other files in the same way.
Try a few more times rosdep update
and it may succeed. I can only tell you that I failed, so continue to change, I changed the timeout time to 500, and it still timed out. . .
Well, this is nowhere. For the ultimate method, please see method three.
(3) Method 3
What I said earlier rosdep update
is to download the corresponding file according 20-default.list
to the URL link ( "raw.githubusercontent.com"
) in the file. Since it cannot be downloaded over the Internet, can I download it manually? The answer is yes.
raw.githubusercontent.com is actually the user data server of github, and the files downloaded by the rosdep program are the files in the repository github.com/ros/rosdistro.
Execute the following command:
git clone https://github.com/ros/rosdistro.git
(Of course, you can go directly to the https://github.com/ros/rosdistro.git
point of Download Zip
download)
The internet speed may be a bit slow, don’t worry, you can download it from the CSDN resource I provided, click for free download: ROS installation file rosdistro-master.zip .
Will download into a rosdistro-master.zip
folder named in the current directory , all the files mentioned above are in it.
First unzip this file, and then put it in a new directory, I put it /etc/ros
under, execute the command (the specific path is modified according to your directory )
sudo cp -r /home/ubuntu/Documents/rosdistro-master /etc/ros
First modify 20-default.list
, execute:
sudo gedit /etc/ros/rosdep/sources.list.d/20-default.list
"raw.githubusercontent.com"
Replace all the content linked to in it with the link to the local file, the final 20-default.list
content is like this (the specific file path is changed according to the location you put ):
# os-specific listings first
#yaml https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml osx
yaml file:///etc/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
yaml file:///etc/ros/rosdistro-master/rosdep/base.yaml
yaml file:///etc/ros/rosdistro-master/rosdep/python.yaml
yaml file:///etc/ros/rosdistro-master/rosdep/ruby.yaml
gbpdistro file:///etc/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
Then modify the following three files, and also "raw.githubusercontent.com"
replace all the contents linked to with links to local files. You can use Ctrl+ to Ffind raw.githubusercontent.com
, there is one place in each file that needs to be modified.
1. /usr/lib/python2.7/dist-packages/rosdep2/gbpdistro_support.py
2. /usr/lib/python2.7/dist-packages/rosdep2/rep3.py
3. /usr/lib/python2.7/dist-packages/rosdistro/__init__.py
Modify gbpdistro_support.py
, execute:
sudo gedit /usr/lib/python2.7/dist-packages/rosdep2/gbpdistro_support.py
Locate raw.githubusercontent.com
this line (use Ctrl+ Fsearch), comment out the original link and change it to a local file. The modified content is as follows:
# FUERTE_GBPDISTRO_URL = 'https://raw.githubusercontent.com/ros/rosdistro/master/releases/fuerte.yaml'
FUERTE_GBPDISTRO_URL = 'file:///etc/ros/rosdistro-master/releases/fuerte.yaml'
The screenshot in the file is like this:
modify rep3.py
, execute:
sudo gedit /usr/lib/python2.7/dist-packages/rosdep2/rep3.py
Also locate raw.githubusercontent.com
this line (use Ctrl+ Fsearch), comment out the original link and change it to a local file. The modified content is as follows:
# REP3_TARGETS_URL = 'https://raw.githubusercontent.com/ros/rosdistro/master/releases/targets.yaml'
REP3_TARGETS_URL = 'file:etc/ros/rosdistro-master/releases/targets.yaml'
Modify __init__.py
, execute:
sudo gedit /usr/lib/python2.7/dist-packages/rosdistro/__init__.py
Also locate raw.githubusercontent.com
this line (use Ctrl+ Fsearch), comment out the original link and change it to a local file. The modified content is as follows:
# DEFAULT_INDEX_URL = 'https://raw.githubusercontent.com/ros/rosdistro/master/index-v4.yaml'
DEFAULT_INDEX_URL = 'file:///etc/ros/rosdistro-master/index-v4.yaml'
Ok, execute it again rosdep update
, this time it must be successful, and the result is shown below.