Repository: espanso/espanso (language: rust)

Issue:
Unexpected exit code from worker 90 on Wayland
Now espanso was finally working fine on Wayland, but as of yesterday it stopped working. :/

`espanso start` appears to start espanso, but the replacements aren't working. And if I execute `espanso restart`, it says that espanso wasn't running, but it also doesn't start it.

`#acfg#` and `#pacfg#` aren't working either, but the log does say that it quit with an unexpected exit code.

```
& thefish @ hx90 in ~/fromsvngit/espanso (master ✔) 0 [11:32:36]
~ espanso log
11:32:38 [daemon(673798)] [INFO] reading configs from: "/home/thefish/.config/espanso"
11:32:38 [daemon(673798)] [INFO] reading packages from: "/home/thefish/.config/espanso/match/packages"
11:32:38 [daemon(673798)] [INFO] using runtime dir: "/home/thefish/.local/share/espanso"
11:32:38 [daemon(673798)] [WARN] keyboard layout watcher couldn't determine active layout.
11:32:38 [daemon(673798)] [INFO] watching for changes in path: "/home/thefish/.config/espanso"
11:32:38 [daemon(673798)] [INFO] espanso version: 2.1.5-beta
11:32:38 [daemon(673798)] [INFO] spawning the worker process...
11:32:38 [daemon(673798)] [INFO] binded to IPC unix socket: /home/thefish/.local/share/espanso/espansodaemonv2.sock
11:32:38 [worker(673804)] [INFO] reading configs from: "/home/thefish/.config/espanso"
11:32:38 [worker(673804)] [INFO] reading packages from: "/home/thefish/.config/espanso/match/packages"
11:32:38 [worker(673804)] [INFO] using runtime dir: "/home/thefish/.local/share/espanso"
11:32:38 [worker(673804)] [INFO] binded to IPC unix socket: /home/thefish/.local/share/espanso/espansoworkerv2.sock
11:32:38 [worker(673804)] [INFO] monitoring the status of the daemon process
11:32:38 [worker(673804)] [INFO] using WaylandAppInfoProvider
11:32:38 [worker(673804)] [INFO] detection module will use this keyboard layout: [R=evdev, M=pc86, L=us, V=dvorak-intl, O=terminate:ctrl_alt_bksp]
11:32:38 [worker(673804)] [INFO] using EVDEVSource
11:32:38 [worker(673804)] [INFO] Querying modifier status...
11:32:39 [daemon(673798)] [ERROR] received unexpected exit code from worker 90, exiting

& thefish @ hx90 in ~/fromsvngit/espanso (master ✔) 0 [11:32:41]
~
```

OS: Arch Linux
KDE: 5.24
Espanso version: latest git master

The matches file isn't corrupt and I didn't even edit it in the past few weeks.

How can we further investigate this?


Discussion / hints:
Hey @Vistaus,

I'm sorry you experienced this problem! Could you please try running the following and post the output here?

```
espanso -vvv worker
```

Cheers :)

Hey Frederico! :)

That command produced some more output:

```
& thefish @ hx90 in ~/Downloads 0 [20:20:12]
~ espanso -vvv worker
22:34:07 [worker(838091)] [DEBUG] (1) espanso_path: detected config directory in $HOME/.config/espanso
22:34:07 [worker(838091)] [DEBUG] (1) espanso_path: detected legacy runtime dir: "/home/thefish/.local/share/espanso"
22:34:07 [worker(838091)] [DEBUG] (1) espanso_path: detected default packages dir: "/home/thefish/.config/espanso/match/packages"
22:34:07 [worker(838091)] [INFO] reading configs from: "/home/thefish/.config/espanso"
22:34:07 [worker(838091)] [INFO] reading packages from: "/home/thefish/.config/espanso/match/packages"
22:34:07 [worker(838091)] [INFO] using runtime dir: "/home/thefish/.local/share/espanso"
22:34:07 [worker(838091)] [DEBUG] (1) espanso_config::config::store: loaded default config at path: "/home/thefish/.config/espanso/config/default.yml"
22:34:07 [worker(838091)] [DEBUG] (1) espanso_config::config::store: loaded config at path: "/home/thefish/.config/espanso/config/firefox.yml"
22:34:07 [worker(838091)] [DEBUG] (1) espanso::patch::config_store: skipping 'alacritty_terminal_x11' patch
22:34:07 [worker(838091)] [DEBUG] (1) espanso::patch::config_store: skipping 'emacs_x11' patch
22:34:07 [worker(838091)] [DEBUG] (1) espanso::patch::config_store: skipping 'gedit_x11' patch
22:34:07 [worker(838091)] [DEBUG] (1) espanso::patch::config_store: skipping 'generic_terminal_x11' patch
22:34:07 [worker(838091)] [DEBUG] (1) espanso::patch::config_store: skipping 'kitty_terminal_x11' patch
22:34:07 [worker(838091)] [DEBUG] (1) espanso::patch::config_store: skipping 'konsole_terminal_x11' patch
22:34:07 [worker(838091)] [DEBUG] (1) espanso::patch::config_store: skipping 'libreoffice_writer_x11' patch
22:34:07 [worker(838091)] [DEBUG] (1) espanso::patch::config_store: skipping 'simple_terminal_x11' patch
22:34:07 [worker(838091)] [DEBUG] (1) espanso::patch::config_store: skipping 'simple_terminal_2_x11' patch
22:34:07 [worker(838091)] [DEBUG] (1) espanso::patch::config_store: skipping 'terminator_terminal_x11' patch
22:34:07 [worker(838091)] [DEBUG] (1) espanso::patch::config_store: skipping 'termite_terminal_x11' patch
22:34:07 [worker(838091)] [DEBUG] (1) espanso::patch::config_store: skipping 'thunderbird_x11' patch
22:34:07 [worker(838091)] [DEBUG] (1) espanso::patch::config_store: skipping 'tilix_terminal_x11' patch
22:34:07 [worker(838091)] [DEBUG] (1) espanso::patch::config_store: skipping 'urxvt_terminal_x11' patch
22:34:07 [worker(838091)] [DEBUG] (1) espanso::patch::config_store: skipping 'xterm_terminal_x11' patch
22:34:07 [worker(838091)] [DEBUG] (1) espanso::patch::config_store: skipping 'yakuake_terminal_x11' patch
22:34:07 [worker(838091)] [DEBUG] (1) espanso::patch::config_store: skipping 'virtualbox_x11' patch
22:34:07 [worker(838091)] [DEBUG] (1) espanso::cli::worker: starting with start-reason = None
22:34:07 [worker(838091)] [DEBUG] (1) espanso::icon: skipping extraction for '"/home/thefish/.local/share/espanso/iconv2.png"', as it's already present
22:34:07 [worker(838091)] [DEBUG] (1) espanso::icon: skipping extraction for '"/home/thefish/.local/share/espanso/search.png"', as it's already present
22:34:07 [worker(838091)] [DEBUG] (1) espanso::icon: skipping extraction for '"/home/thefish/.local/share/espanso/icon_no_background.png"', as it's already present
22:34:07 [worker(838091)] [INFO] binded to IPC unix socket: /home/thefish/.local/share/espanso/espansoworkerv2.sock
22:34:07 [worker(838091)] [INFO] using WaylandAppInfoProvider
22:34:07 [worker(838091)] [DEBUG] (2) espanso::cli::worker::engine: using linux capabilities to grant permissions needed by EVDEV backend
22:34:07 [worker(838091)] [DEBUG] (2) espanso::cli::worker::engine: successfully granted permissions using capabilities
22:34:07 [worker(838091)] [INFO] detection module will use this keyboard layout: [R=evdev, M=pc104, L=us, V=dvorak-intl, O=]
22:34:07 [worker(838091)] [INFO] using EVDEVSource
22:34:07 [worker(838091)] [INFO] Querying modifier status...
[wayland-client error] Attempted to dispatch unknown opcode 0 for wl_shm, aborting.
fish: Job 1, 'espanso -vvv worker' terminated by signal SIGABRT (Abort)

& thefish @ hx90 in ~/Downloads 0 [22:34:08]
~
```
@Vistaus Thanks! That's interesting. Did you make some changes with your Desktop Environment? It seems something is wrong with the wayland protocol exchange
@federico-terzi No, I'm still using the same KDE Plasma that I was using before.
@Vistaus Interesting, I don't have many ideas at the moment but I'll definitely investigate :)
@federico-terzi That'd be great. Thank you for looking into it! :)
I missed Espanso too much, so I couldn't wait for this to be solved. So I switched to openSUSE Tumbleweed, eventually got Espanso to compile and now it's working again. So I'll close this issue. :)
It's back again after the Plasma 5.25 update on openSUSE Tumbleweed today. espanso can't be started anymore because of this issue... :(
The output of espanso -vvv worker is the same as above.
I hope this can be fixed. I really miss Espanso (esp. when using it for work). :(
I can reproduce this issue. 
```
❯ ./target/release/espanso daemon                                                                              at  19:25:03
19:25:03 [daemon(73121)] [INFO] reading configs from: "/home/ss/.config/espanso"
19:25:03 [daemon(73121)] [INFO] reading packages from: "/home/ss/.config/espanso/match/packages"
19:25:03 [daemon(73121)] [INFO] using runtime dir: "/home/ss/.cache/espanso"
19:25:03 [daemon(73121)] [INFO] system info: Fedora Linux v36 - kernel: 5.18.13-200.fc36.x86_64
19:25:03 [daemon(73121)] [INFO] watching for changes in path: "/home/ss/.config/espanso"
19:25:03 [daemon(73121)] [INFO] espanso version: 2.1.7-beta
19:25:03 [daemon(73121)] [INFO] spawning the worker process...
19:25:03 [daemon(73121)] [INFO] binded to IPC unix socket: /home/ss/.cache/espanso/espansodaemonv2.sock
19:25:03 [worker(73128)] [INFO] reading configs from: "/home/ss/.config/espanso"
19:25:03 [worker(73128)] [INFO] reading packages from: "/home/ss/.config/espanso/match/packages"
19:25:03 [worker(73128)] [INFO] using runtime dir: "/home/ss/.cache/espanso"
19:25:03 [worker(73128)] [INFO] system info: Fedora Linux v36 - kernel: 5.18.13-200.fc36.x86_64
19:25:03 [worker(73128)] [INFO] using WaylandAppInfoProvider
19:25:03 [worker(73128)] [INFO] binded to IPC unix socket: /home/ss/.cache/espanso/espansoworkerv2.sock
19:25:03 [worker(73128)] [WARN] this version of espanso doesn't come with modulo support, so graphical features (such as Forms and Search) might not be available
19:25:03 [worker(73128)] [WARN] EVDEV backend is being used, but without enabling linux capabilities.
19:25:03 [worker(73128)] [WARN]   Although you CAN run espanso EVDEV backend as root, it's not recommended due
19:25:03 [worker(73128)] [WARN]   to security reasons. Espanso supports linux capabilities to limit the attack surface
19:25:03 [worker(73128)] [INFO] monitoring the status of the daemon process
19:25:03 [worker(73128)] [WARN]   area by only leveraging on the CAP_DAC_OVERRIDE capability (needed to work with
19:25:03 [worker(73128)] [WARN]   /dev/input/* devices to detect and inject text) and disabling it as soon as the
19:25:03 [worker(73128)] [WARN]   initial setup is completed.
19:25:03 [worker(73128)] [INFO] detection module will use this keyboard layout: [R=, M=, L=us, V=, O=]
19:25:03 [worker(73128)] [INFO] using EVDEVSource
19:25:03 [worker(73128)] [INFO] Querying modifier status...
[wayland-client error] Attempted to dispatch unknown opcode 0 for wl_shm, aborting.
19:25:03 [daemon(73121)] [ERROR] received unexpected exit code from worker 90, exiting

```
KDE Plasma again, on Fedora Kinoite. 
Same problem under Archlinux with KDE 5.97.0 / Plasma 5.25.4 (plasma wayland session)
Please check if you have installed wl-clipboard?  At one point there was an overlooked or not-mentioned dependency for this. At one time, I believe I was getting a "worker 90" type of error. My logs:

$ espanso stop
$ espanso daemon
 21:56:15 [daemon(12924)] [INFO] reading configs from: "/home/ykill/.config/espanso"
 21:56:15 [daemon(12924)] [INFO] reading packages from: "/home/ykill/.config/espanso/match/packages"
 21:56:15 [daemon(12924)] [INFO] using runtime dir: "/home/ykill/.cache/espanso"
 21:56:15 [daemon(12924)] [INFO] system info: openSUSE Tumbleweed v20220925 - kernel: 5.19.10-1-default
 21:56:15 [daemon(12924)] [INFO] espanso version: 2.1.7-beta
 21:56:15 [daemon(12924)] [INFO] spawning the worker process...
 21:56:15 [daemon(12924)] [INFO] watching for changes in path: "/home/ykill/.config/espanso"
 21:56:15 [daemon(12924)] [INFO] binded to IPC unix socket: /home/ykill/.cache/espanso/espansodaemonv2.sock
 21:56:15 [daemon(12924)] [WARN] keyboard layout watcher couldn't determine active layout.
 21:56:15 [worker(12931)] [INFO] reading configs from: "/home/ykill/.config/espanso"
 21:56:15 [worker(12931)] [INFO] reading packages from: "/home/ykill/.config/espanso/match/packages"
 21:56:15 [worker(12931)] [INFO] using runtime dir: "/home/ykill/.cache/espanso"
 21:56:15 [worker(12931)] [INFO] system info: openSUSE Tumbleweed v20220925 - kernel: 5.19.10-1-default
 21:56:15 [worker(12931)] [INFO] binded to IPC unix socket: /home/ykill/.cache/espanso/espansoworkerv2.sock
 21:56:15 [worker(12931)] [INFO] using WaylandAppInfoProvider
 21:56:15 [worker(12931)] [INFO] monitoring the status of the daemon process
 21:56:15 [worker(12931)] [INFO] detection module will use this keyboard layout: [R=, M=, L=us, V=, O=]
 21:56:15 [worker(12931)] [INFO] using EVDEVSource
 21:56:16 [worker(12931)] [INFO] Querying modifier status...
 21:56:16 [worker(12931)] [INFO] inject module will use this keyboard layout: [R=, M=, L=us, V=, O=]
 21:56:16 [worker(12931)] [INFO] using EVDEVInjector
 21:56:16 [worker(12931)] [INFO] using WaylandFallbackClipboard

At this point, I can test, and espanso is working. I don't see any further log messages. Please excuse my formatting at this time.

I originally had used a AppImage for espanso, however I now compile from source.

I added: 
wl-clipboard-2.1.0-1.4.x86_64

My setup:
openSUSE TW current
gnome-session-wayland-43
xwayland-22.1.3-1.2


@ykill wl-clipboard is installed for me, however, it's still not working on my openSUSE TW install.
I have the same issue on Arch with KDE 5.26.2. I tried going back to the 2.1.5 beta and it still didn't work. I'm going to try going back further, but perhaps this line from the `espanso -vvv worker` output is helpful (seems like everyone above has the same error):

`[wayland-client error] Attempted to dispatch unknown opcode 0 for wl_shm, aborting.`

I'll report back if I have any success with older versions of espanso.

**Update**: I just went back and tried a few versions all the way back to espanso 2.0.3-alpha and none of them worked, so this may be an issue with a recent KDE update, because I'm quite certain I used that version on KDE Wayland about a year ago. Not sure if this is something that needs to be fixed in espanso or in KDE. 

For now it's quite unfortunate and it's making me choose between espanso and KDE.

**Update 2**: I switched to the LTS kernel (5.15.75) just in case that had any effect and that didn't help either.

Fix patch:
diff --git a/espanso-detect/Cargo.toml b/espanso-detect/Cargo.toml
index b97c457e..5d44316e 100644
--- a/espanso-detect/Cargo.toml
+++ b/espanso-detect/Cargo.toml
@@ -24,10 +24,10 @@ widestring = "0.4.3"
 [target.'cfg(target_os="linux")'.dependencies]
 libc = "0.2.85"
 scopeguard = "1.1.0"
-sctk = { package = "smithay-client-toolkit", version = "0.14.0", optional = true }
+sctk = { package = "smithay-client-toolkit", version = "0.15.4", optional = true }
 
 [build-dependencies]
 cc = "1.0.73"
 
 [dev-dependencies]
-enum-as-inner = "0.3.3"
\ No newline at end of file
+enum-as-inner = "0.3.3"


Test patch: