Pacman-mirrors throwing UnboundLocalError

Out of nowhere (no recent major changes or updates on the system, at least as far as I remember :wink: pacman-mirrors threw this one:

[frog ~]# pacman-mirrors   
Pacman-mirrors version 4.21.5
Traceback (most recent call last):
  File "/usr/bin/pacman-mirrors", line 28, in <module>
    pm.run()
  File "/usr/lib/python3.9/site-packages/pacman_mirrors/pacman_mirrors.py", line 93, in run
    cliFn.parse_command_line(self, gtk_available=GTK_AVAILABLE)
  File "/usr/lib/python3.9/site-packages/pacman_mirrors/functions/cliFn.py", line 176, in parse_command_line
    exit_code = mirror_status.print_status(self)
  File "/usr/lib/python3.9/site-packages/pacman_mirrors/functions/mirror_status.py", line 64, in print_status
    system_branch, mirrors_pacman = get_local_mirrors()
  File "/usr/lib/python3.9/site-packages/pacman_mirrors/functions/mirror_status.py", line 31, in get_local_mirrors
    return mirror_branch, urls
UnboundLocalError: local variable 'mirror_branch' referenced before assignment

I could get it to “behave” again by just executing pacman-mirrors --geoip.

But I think this error might be easy to fix and I would even look into it. Any points in the right direction on how to submit fixes/file bugs would be helpful. In this case I suppose it needs to be filed in archlinux/pacman right? Thanks for any hints. Manjaro/Arch newbie here :slight_smile:

I’m not sure if it’s related but usually pacman-mirrors should be used using sudo instead of su. Also, make sure you have taken care on older pacnew files.

strange, when i read code, /etc/pacman.d/mirrorlist is empty for you ??? (no line " Server = xxx")

First and foremost - pacman-mirrors is Manjaro specific - it has nothing to do with upstream pacman or upstream mirrorlist.

When you run pacman-mirrors with no arguments - it reads the local mirrorlist to be able to compare the list to the status fetched from the repo server.

The error indicates you have no mirror list - and this is very unusual.

1 Like

Doesn’t make any difference, so long as ${EUID} equals 0:wink:

I always use it from within the root account, which I log into via su -. :wink:

1 Like

Thanks a lot for fixing!