WSL: add-apt-repository not working with Ubuntu & Pengwin
Windows build number : 18975.1000 WSL version : 2
I was using wsl 1 without any issue before and was able to add some ppa with a command like the following
sudo add-apt-repository ppa:ondrej/nginx
Yesterday I went to Windows Fast Ring to test WSL2. I removed the Ubuntu distro which was working before and started fresh to see what improvements could have been made.
Whenever I’m trying to add a ppa it always hang. I cancel the operation with ctrl+c to see some python errors:
sudo add-apt-repository ppa:ondrej/nginx
This branch follows latest NGINX Stable packages compiled against latest OpenSSL for HTTP/2 and TLS 1.3 support.
BUGS&FEATURES: This PPA now has a issue tracker: https://deb.sury.org/#bug-reporting
PLEASE READ: If you like my work and want to give me a little motivation, please consider donating: https://donate.sury.org
More info: https://launchpad.net/~ondrej/+archive/ubuntu/nginx
Press [ENTER] to continue or ctrl-c to cancel adding it
^CTraceback (most recent call last):
File "/usr/bin/add-apt-repository", line 168, in <module>
if not sp.add_source_from_shortcut(shortcut, options.enable_source):
File "/usr/lib/python3/dist-packages/softwareproperties/SoftwareProperties.py", line 737, in add_source_from_shortcut
worker = self.check_and_add_key_for_whitelisted_shortcut(shortcut)
File "/usr/lib/python3/dist-packages/softwareproperties/SoftwareProperties.py", line 678, in check_and_add_key_for_whitelisted_shortcut
codename=self.distro.codename, distro=self.distro.id.lower())
File "/usr/lib/python3/dist-packages/softwareproperties/ppa.py", line 371, in expand
codename = get_current_series_from_lp(self._info["distribution"])
File "/usr/lib/python3/dist-packages/softwareproperties/ppa.py", line 96, in get_current_series_from_lp
return os.path.basename(get_info_from_lp(lp_url)["current_series_link"])
File "/usr/lib/python3/dist-packages/softwareproperties/ppa.py", line 88, in get_info_from_lp
return _get_https_content_py3(lp_url)
File "/usr/lib/python3/dist-packages/softwareproperties/ppa.py", line 102, in _get_https_content_py3
lp_page = urllib.request.urlopen(request, cafile=LAUNCHPAD_PPA_CERT)
File "/usr/lib/python3.7/urllib/request.py", line 222, in urlopen
return opener.open(url, data, timeout)
File "/usr/lib/python3.7/urllib/request.py", line 525, in open
response = self._open(req, data)
File "/usr/lib/python3.7/urllib/request.py", line 543, in _open
'_open', req)
File "/usr/lib/python3.7/urllib/request.py", line 503, in _call_chain
result = func(*args)
File "/usr/lib/python3.7/urllib/request.py", line 1360, in https_open
context=self._context, check_hostname=self._check_hostname)
File "/usr/lib/python3.7/urllib/request.py", line 1317, in do_open
encode_chunked=req.has_header('Transfer-encoding'))
File "/usr/lib/python3.7/http/client.py", line 1244, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/usr/lib/python3.7/http/client.py", line 1290, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/usr/lib/python3.7/http/client.py", line 1239, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/usr/lib/python3.7/http/client.py", line 1026, in _send_output
self.send(msg)
File "/usr/lib/python3.7/http/client.py", line 966, in send
self.connect()
File "/usr/lib/python3.7/http/client.py", line 1406, in connect
super().connect()
File "/usr/lib/python3.7/http/client.py", line 938, in connect
(self.host,self.port), self.timeout, self.source_address)
File "/usr/lib/python3.7/socket.py", line 716, in create_connection
sock.connect(sa)
KeyboardInterrupt
I tested on Ubuntu (18.04 & 19.10) & with Pengwin. Note that on pengwin I was needed to install this package:
sudo apt install -y software-properties-common
I have Kaspersky and tried to disable it, it didn’t change anything. At some point, some ppa’s get added but I have no idea why as usually it fails with some errors.
Any idea if it’s a bug or something else ?
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 2
- Comments: 15 (1 by maintainers)
I typed too quickly/blindly in my previous test. For reasons unknown, using the generated
/etc/resolv.conf(which points back to Windows as the nameserver) was failing to resolve the Ubuntu hostnames. Changingresolve.confto point at 8.8.8.8 (without the brain fart) fixed the problem.I’m convinced there is something strange happening with the name resolution; I could add ppas before “just recently” (meaning, trying your repro) with the generated
resolv.conf. It isn’t certificates; you wouldn’t be able toapt-anything without certs.In any case, inviting Kaspersky to the discussion is almost certainly a thread killer.
Disabling IPV6 in Windows fixed this.
If you don’t want to disable IPV6 in Windows, you can change the precedence in the WSL disto to iv4.
use:
sudo nano /etc/gai.congUncomment line:precedence ::ffff:0:0/96 100Tested on WSL with Ubuntu 18.04
sudo apt install -y software-properties-commonfixed this for me in Pengwin.Was able to reproduce this on Ubuntu Disco and 18975. My mode of fail was slightly different. It is resolver related alright, but I can’t say wut. [edit, guh] Tried the usual big hammer
sudo sh -c "echo 'nameserver 8.8.8.8' > /etc/resolv.conf"~but no joy~ which resolved more below.