Whonix-gateway-17 update error after template upgrade

Hello, I went through Template Manager today and I saw fedora-41 available for install which I selected, as well as an upgrade available for whonix-gateway-17 and whonix-workstation-17, but they were the community-testing versions, but still I opted for the upgrade.

After upgrading, both of them required updates. whonix-workstation-17 was able to update successfully, whonix-gateway-17 did not. It instantly errors out and here is the error message:

Updating whonix-gateway-17
Refreshing package info
Traceback (most recent call last):
  File "/run/qubes-update/agent/entrypoint.py", line 98, in <module>
    sys.exit(main())
             ^^^^^^
  File "/run/qubes-update/agent/entrypoint.py", line 28, in main
    return_code = pkg_mng.upgrade(refresh=not args.no_refresh,
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/run/qubes-update/agent/source/common/package_manager.py", line 57, in upgrade
    result = self._upgrade(
             ^^^^^^^^^^^^^^
  File "/run/qubes-update/agent/source/common/package_manager.py", line 94, in _upgrade
    result_refresh = self.refresh(hard_fail)
                     ^^^^^^^^^^^^^^^^^^^^^^^
  File "/run/qubes-update/agent/source/apt/apt_api.py", line 56, in refresh
    self.wait_for_lock()
  File "/run/qubes-update/agent/source/apt/apt_cli.py", line 55, in wait_for_lock
    with self.apt_lock():
  File "/usr/lib/python3.11/contextlib.py", line 137, in __enter__
    return next(self.gen)
           ^^^^^^^^^^^^^^
  File "/run/qubes-update/agent/source/apt/apt_cli.py", line 47, in apt_lock
    with open("/var/lib/apt/lists/lock", "rb+") as f_lock:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/var/lib/apt/lists/lock'



Has anyone experienced this? How do I fix it? I would prefer not to have to revert to the stable one.

Thank you.

1 Like

Hey guys, first day on Qubes, & I’m loving it so far. Just trying to update everything like the installation guide recommends. However I’m having some trouble updating whonix, everything else updated successfully. The weird thing is, immediately post-install, whonix updated itself, and about a hour later a new update was available. Going to post my error message below.

Updating whonix-workstation-17
Traceback (most recent call last):
Refreshing package info
  File "/run/qubes-update/agent/entrypoint.py", line 98, in <module>
    sys.exit(main())
             ^^^^^^
  File "/run/qubes-update/agent/entrypoint.py", line 28, in main
    return_code = pkg_mng.upgrade(refresh=not args.no_refresh,
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/run/qubes-update/agent/source/common/package_manager.py", line 57, in upgrade
    result = self._upgrade(
             ^^^^^^^^^^^^^^
  File "/run/qubes-update/agent/source/common/package_manager.py", line 94, in _upgrade
    result_refresh = self.refresh(hard_fail)
                     ^^^^^^^^^^^^^^^^^^^^^^^
  File "/run/qubes-update/agent/source/apt/apt_api.py", line 56, in refresh
    self.wait_for_lock()
  File "/run/qubes-update/agent/source/apt/apt_cli.py", line 55, in wait_for_lock
    with self.apt_lock():
  File "/usr/lib/python3.11/contextlib.py", line 137, in __enter__
    return next(self.gen)
           ^^^^^^^^^^^^^^
  File "/run/qubes-update/agent/source/apt/apt_cli.py", line 47, in apt_lock
    with open("/var/lib/apt/lists/lock", "rb+") as f_lock:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/var/lib/apt/lists/lock'

Thanks

2 Likes

Could you explain a bit further what exactly happened? Whonix doesn’t just update itself out of nowhere.

Nevertheless, it could be possible that another apt process is running in the background, which could be causing some weird issues. You can check it with the following command:

ps aux | grep apt

If that’s the case, kill the process and don’t forget to run sudo dpkg --configure -a afterwards.

The error message suggests that the lock file /var/lib/apt/lists/lock is missing. This could indicate that for some reason the directory itself is not there. You can manually create it using:

sudo mkdir -p /var/lib/apt/lists/

Even though the error suggests that the lock file is missing, it doesn’t hurt to make sure that any leftover lock file from an old process is deleted:

sudo rm -f /var/lib/apt/lists/lock
sudo rm -f /var/cache/apt/archives/lock
sudo rm -f /var/lib/dpkg/lock*

Afterwards, try to manually update the system by running sudo apt update && sudo apt upgrade -y

2 Likes

Nevertheless, it could be possible that another apt process is running in the background, which could be causing some weird issues.

I ran that command and this is what came up:

ps aux | grep apt
rookie          57721  0.0  0.0 222020  2048 pts/22   S+   15:17   0:00 grep --color=auto apt

Would this be the cause? How do I kill it if so?

Thank you

1 Like

Looks like updater bug, copied report to qubes-vm-update fails on freshly installed whonix template · Issue #9857 · QubesOS/qubes-issues · GitHub

In the meantime, you can fix your template by simply running sudo apt-get update in it.

2 Likes

Fixed! Thank you

1 Like

That is not the cause. That is the grep command you have just issued.
There is no other apt process running at that time.

Have you checked that /var/lib/apt/lists/ exists?

I never presume to speak for the Qubes team.
When I comment in the Forum I speak for myself.

1 Like

@rookie: can you mark as solved?

This worked for me as well.

1 Like

I would but I really cannot find any buttons to mark it as solved. If a moderator could that would be great.

Thank you for all the help

1 Like
E:   Could not get lock /var/lib/apt/lists/lock.   It is held by process 13886 (apt-get.anondis)
E:   Unable to lock directory /var/lib/apt/lists/

I am not sure what to do if anything.

1 Like

Are you trying to run apt update manually? Process 13886 might be an automatic update, just wait a bit and try again

1 Like
Updating whonix-workstation-17
Traceback (most recent call last):
  File "/run/qubes-update/agent/entrypoint.py", line 98, in <module>
    sys.exit(main())
             ^^^^^^
  File "/run/qubes-update/agent/entrypoint.py", line 28, in main
    return_code = pkg_mng.upgrade(refresh=not args.no_refresh,
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/run/qubes-update/agent/source/common/package_manager.py", line 57, in upgrade
    result = self._upgrade(
             ^^^^^^^^^^^^^^
  File "/run/qubes-update/agent/source/common/package_manager.py", line 94, in _upgrade
    result_refresh = self.refresh(hard_fail)
                     ^^^^^^^^^^^^^^^^^^^^^^^
  File "/run/qubes-update/agent/source/apt/apt_api.py", line 56, in refresh
    self.wait_for_lock()
  File "/run/qubes-update/agent/source/apt/apt_cli.py", line 55, in wait_for_lock
    with self.apt_lock():
  File "/usr/lib/python3.11/contextlib.py", line 137, in __enter__
    return next(self.gen)
           ^^^^^^^^^^^^^^
Refreshing package info
  File "/run/qubes-update/agent/source/apt/apt_cli.py", line 47, in apt_lock
    with open("/var/lib/apt/lists/lock", "rb+") as f_lock:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/var/lib/apt/lists/lock'

Unsure of what to exactly do about this, I never did anything as this is a brand new installation of Qubes OS; I installed Qubes OS yesterday. On top of this when I make a new Whonix qube the Whonix gateway always denies it access to the Internet.

1 Like

You can fix your template by manually running sudo apt-get update in it:

1 Like

Thank you this worked :saluting_face:

3 dots at bottom of post with answer should have “Solution” option for you as the original poster, will help others who are coming here for same problem.

1 Like