Starting with a PC happily running Ubuntu 18.04 desktop, I copied the entire drive as a backup, then tried to upgrade it to 22.04. Running do-release-upgrade brought it up to 20.04, and it seems happy running that. After a few reboots I tried upgrading it from 20.04 to 22.04. It always hangs in the same spot, right after:
Get:184 http://ports.ubuntu.com/ubuntu-ports jammy-backports/universe DEP-11 64x64 Icons [13.4 kB]
Get:185 http://ports.ubuntu.com/ubuntu-ports jammy-backports/universe amd64 c-n-f Metadata [480 B]
Get:186 http://ports.ubuntu.com/ubuntu-ports jammy-backports/multiverse amd64 c-n-f Metadata [116 B]
Fetched 504 MB in 6s (0 B/s)
The longest I've left it like that is at least a few hours. It's stuck. Control-C gets out of it, and the traceback is:
Traceback (most recent call last):
File "/usr/lib/cnf-update-db", line 27, in <module>
col.create(db)
File "/usr/lib/python3/dist-packages/CommandNotFound/db/creator.py", line 95, in create
self._fill_commands(con)
File "/usr/lib/python3/dist-packages/CommandNotFound/db/creator.py", line 140, in _fill_commands
if sub.wait() != 0:
File "/usr/lib/python3.8/subprocess.py", line 1083, in wait
return self._wait(timeout=timeout)
File "/usr/lib/python3.8/subprocess.py", line 1806, in _wait
(pid, sts) = self._try_wait(0)
File "/usr/lib/python3.8/subprocess.py", line 1764, in _try_wait
(pid, sts) = os.waitpid(self.pid, wait_flags)
At work we have a VM that had the same problem, going from 20.04 to 22.04. In the end they wound up just making a fresh 22.04 VM. I do some work stuff on this PC, so it's possible some particular package is to blame and both systems had that package installed.
While it's in that state:
# tail -n 10 /var/log/dist-upgrade/main.log
2023-04-02 12:29:04,801 DEBUG url_downloadable: http://ports.ubuntu.com/ubuntu-ports//dists/jammy/Release
2023-04-02 12:29:04,801 DEBUG s='http' n='ports.ubuntu.com' p='/ubuntu-ports//dists/jammy/Release' q='' f=''
2023-04-02 12:29:04,980 DEBUG entry 'deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ jammy main restricted universe multiverse' updated to new dist
2023-04-02 12:29:04,980 DEBUG examining: 'deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ focal-updates main restricted universe multiverse'
2023-04-02 12:29:04,980 DEBUG entry 'deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ jammy-updates main restricted universe multiverse' updated to new dist
2023-04-02 12:29:04,980 DEBUG examining: 'deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ focal-security main restricted universe multiverse'
2023-04-02 12:29:04,980 DEBUG entry 'deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ jammy-security main restricted universe multiverse' updated to new dist
2023-04-02 12:29:04,981 DEBUG examining: 'deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ focal-backports main restricted universe multiverse'
2023-04-02 12:29:04,981 DEBUG entry 'deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ jammy-backports main restricted universe multiverse' updated to new dist
2023-04-02 12:29:04,986 DEBUG running doUpdate() (showErrors=True)
I've tried a lot of different things suggested in other threads here. For example I moved all .list files from /etc/apt/ and /etc/apt/sources.list.d/ that had anything but "focal" listed (some had been "bionic"). And for example I can run these commands after a reboot, and I get the same issue:
apt-get clean
apt --fix-broken install
apt-get update
apt-get upgrade
apt-get clean
do-release-upgrade
dpkg --print-architecture and dpkg --print-foreign-architectures please edit your question for that.
scott@scott-XPS-8900:~$ dpkg --print-architecture
amd64
scott@scott-XPS-8900:~$ dpkg --print-foreign-architectures
i386
arm64
The aforementioned work stuff involves compiling for arm64. I'm not sure why i386 is there (EDIT: "dpkg --list | grep i36" says "syslinux-legacy").
UPDATE: There are no longer any foreign architectures. I purged those packages and removed the i386 and arm64 architectures as described in How to remove all i386 packages from Ubuntu 64bit?. No improvement.
it looks for me something with python/python3 is broken. sudo apt update
Earlier on I tried:
sudo apt-get install --reinstall python3-apt
At the moment "apt update" is hanging. It wasn't doing that earlier:
scott@scott-XPS-8900:~$ sudo apt update
Hit:1 http://security.ubuntu.com/ubuntu focal-security InRelease
Hit:2 http://ca.archive.ubuntu.com/ubuntu focal InRelease
Hit:3 http://ca.archive.ubuntu.com/ubuntu focal-updates InRelease
Hit:4 http://ca.archive.ubuntu.com/ubuntu focal-backports InRelease
Hit:5 http://ports.ubuntu.com/ubuntu-ports focal InRelease
Hit:6 http://ports.ubuntu.com/ubuntu-ports focal-updates InRelease
Hit:7 http://ports.ubuntu.com/ubuntu-ports focal-security InRelease
Hit:8 http://ports.ubuntu.com/ubuntu-ports focal-backports InRelease
(then it just sits there) After a few minutes, control-C:
Traceback (most recent call last):
File "/usr/lib/cnf-update-db", line 27, in <module>
col.create(db)
File "/usr/lib/python3/dist-packages/CommandNotFound/db/creator.py", line 95, in create
self._fill_commands(con)
File "/usr/lib/python3/dist-packages/CommandNotFound/db/creator.py", line 140, in _fill_commands
if sub.wait() != 0:
File "/usr/lib/python3.8/subprocess.py", line 1083, in wait
return self._wait(timeout=timeout)
File "/usr/lib/python3.8/subprocess.py", line 1806, in _wait
(pid, sts) = self._try_wait(0)
File "/usr/lib/python3.8/subprocess.py", line 1764, in _try_wait
(pid, sts) = os.waitpid(self.pid, wait_flags)
Why are the ports.ubuntu.com repo still active?
It seems they're left over from when I previously had foreign architectures (i386, arm64) enabled. I commented them out in /etc/apt/sources.list
and ran apt update
again. It still hangs.
Then I tried:
sudo pkill cnf-update-db
sudo rm -rf /var/lib/apt/lists/*
sudo apt update``
Again it hangs, and control-C produces the same stack trace as above.
After much digging through the Python code in the control-C backtrace and doing a bunch of searches, I found: CommandNotFound.db.creator import DbCreator on ubuntu
That got apt-get update
going:
sudo apt-get remove --purge python3-apt
sudo apt autoremove
apt-get install python3-apt
# Probably most of the next few commands weren't needed
sudo rm -rf /var/lib/apt/lists/*
sudo apt-get clean
sudo apt-get check
sudo apt --fix-broken install
sudo apt-get update
I'll reboot and try do-release-upgrade
again, and report back.(UPDATE: it worked -- see my posted solution)
dpkg --print-architecture
anddpkg --print-foreign-architectures
please edit your question for that.sudo apt update
please edit your question for output not as comment.ports.ubuntu.com
repo still active?