"ERROR: Cannot fetch updates" logged when adding a custom pacman module
Hi, when adding the alternate custom/pacman module from the waybar wiki this message gets printed when I start waybar:
==> ERROR: Cannot fetch updates
It looks harmless, but I would like to know where it comes from. I could not find it grepping waybar's code.
Running checkupdates manually from the terminal works fine and does not print the error either.
Waybar version is v0.9.18.
Maybe interestingly, a user reports a similar error in this comment on an unrelated issue, but they do not have a custom/pacman module (they do have a custom/pkg module that might do something similar).
My waybar configuration:
{
"layer": "top",
"position": "bottom",
"modules-left": [
"sway/workspaces",
"custom/right-arrow-dark"
],
"modules-center": [
"custom/left-arrow-dark",
"clock#1",
"custom/left-arrow-light",
"custom/left-arrow-dark",
"clock#2",
"custom/right-arrow-dark",
"custom/right-arrow-light",
"clock#3",
"custom/right-arrow-dark"
],
"modules-right": [
"custom/left-arrow-dark",
"pulseaudio",
"custom/left-arrow-light",
"custom/left-arrow-dark",
"memory",
"custom/left-arrow-light",
"custom/left-arrow-dark",
"cpu",
"custom/left-arrow-light",
"custom/left-arrow-dark",
"battery",
"custom/left-arrow-light",
"custom/left-arrow-dark",
"disk",
"custom/left-arrow-light",
"custom/left-arrow-dark",
"custom/pacman",
"custom/left-arrow-light",
"custom/left-arrow-dark",
"tray"
],
"custom/left-arrow-dark": {
"format": "",
"tooltip": false
},
"custom/left-arrow-light": {
"format": "",
"tooltip": false
},
"custom/right-arrow-dark": {
"format": "",
"tooltip": false
},
"custom/right-arrow-light": {
"format": "",
"tooltip": false
},
"sway/workspaces": {
"disable-scroll": true,
"format": "{name}"
},
"clock#1": {
"format": "{:%a}",
"tooltip": false
},
"clock#2": {
"format": "{:%H:%M}",
"tooltip": false
},
"clock#3": {
"format": "{:%b %d}",
"tooltip": false
},
"pulseaudio": {
"format": "{icon} {volume:2}%",
"format-bluetooth": "{icon} {volume}%",
"format-muted": "MUTE",
"format-icons": {
"headphones": "",
"default": [
"",
""
]
},
"scroll-step": 5,
"on-click": "pamixer -t",
"on-click-right": "pavucontrol"
},
"memory": {
"interval": 5,
"format": " {}%"
},
"cpu": {
"interval": 5,
"format": " {load}"
},
"battery": {
"states": {
"good": 90,
"warning": 20,
"critical": 10
},
"format": "{icon} {capacity}%",
"format-icons": [
"",
"",
"",
"",
""
]
},
"disk": {
"format": " {free}",
},
"tray": {
"icon-size": 25
},
"custom/pacman": {
"format": "{} ",
"interval": 3600, // every hour
"exec": "checkupdates | wc -l", // # of updates
"exec-if": "exit 0", // always run; consider advanced run conditions
"on-click": "termite -e 'sudo pacman -Syu'; pkill -SIGRTMIN+8 waybar", // update system
"signal": 8
}
}
I would recommend you put your updates module with a custom script like I've done here: https://gitlab.com/fazzi/dotfiles/-/tree/hyprland/.config/waybar
Thank you @Fxzzi ! I should have mentioned that the module works (although only for pacman packages, AUR updates are not included unlike in your config). But I'd rather not have the error message logged :sweat_smile:
I'm having the same issue, except that the module is NOT working correctly (because the checkupdates script terminates with the error). A quick look at the checkupdates script shows that it's trying to execute "fakeroot -- pacman -Sy", but somehow fails with:
error: failed to synchronize all databases (unable to lock database)
Running this command in a terminal works fine, but not in waybar, even when running as a custom script. Any idea why?
Edit: This seems to fail because it's executed once per waybar - so if I have three monitors (aka three instances of waybar) running, it will run this command three times at the same time, but it will fail because the first instance locks the pacman db.
A workaround for this is to change the CHECKUPDATES_DB environment variable to include the PID of the waybar process, so that each instance has it's own db lock. So the final command looks like this
(CHECKUPDATES_DB="/tmp/checkup-db-${UID}-$$" checkupdates && yay -Qua | wc -l