‘Could not find the Qt platform plugin’

I am trying to distribute my software Brassica as an AppImage. Since this is in most respects a standard Qt application, I was able to follow the instructions in the documentation to create one fairly easily (albeit with a bit of trial-and-error since it depends on some Haskell shared libraries). However, when I attempt to run this AppImage on my machine (EndeavourOS, so practically Arch Linux), I consistently get an error from qt.qpa.plugin that it ‘Could not find the Qt platform plugin’.

The exact form of the error seems to depend on whether I run X11 or Wayland. With X11, I get:

$ ./Brassica.AppImage 
qt.qpa.plugin: Could not find the Qt platform plugin "xcb" in ""
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Aborted (core dumped)

Whereas with Wayland I get:

$ ./Brassica.AppImage 
qt.qpa.plugin: Could not find the Qt platform plugin "wayland" in ""
qt.qpa.plugin: Could not find the Qt platform plugin "xcb" in ""
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Aborted (core dumped)

This behaviour seems to depend on the host system. If I run this AppImage on the same Debian ‘Bullseye’ VM in which it was created, it runs without a problem. However, it appears to be a problem with the AppImage itself rather than my machine: other Qt AppImages seem to open unproblematically, and certainly without complaining about platform plugins. Does anyone have any ideas as to how I can fix this issue?

Well, I’ve managed to half-fix the issue… as discussed in the documentation, copying the correct file to usr/plugins/platforms/libqxcb.so within the AppDir fixes the issue. For my purposes, I also found it useful to copy over the platforminputcontexts so I could use IMEs in my application.

Unfortunately, this solution doesn’t seem to work consistently. It works when I run the AppImage on the same machine it was created on — which previously failed for some machines — but when I try to run the AppImage on a different machine, it fails with the same message. This is despite the fact that mounting with --appimage-mount reveals that the AppImage does in fact contain the correct platform plugins. Some help with this would be greatly appreciated!

Welcome @bradrn.

Are you using linuxdeploy-plugin-qt? Then please ask over at Issues · linuxdeploy/linuxdeploy-plugin-qt · GitHub, since its author isn’t reading here.

Thanks, and much success with your app!