Neither Flatpak nor Snap work: Invalid MIT-MAGIC-COOKIE-1

Apps installed from snap or flatpak do not start. The error seems to be “Invalid MIT-MAGIC-COOKIE-1”.

Try to open ANKI installed with snap:


> env BAMF_DESKTOP_FILE_HINT=/var/lib/snapd/desktop/applications/anki-woodrow_anki.desktop /snap/bin/anki-woodrow.anki %f              (base) 
  File "/snap/anki-woodrow/35/bin/anki", line 3, in <module>
    aqt.run()
  File "/snap/anki-woodrow/35/lib/python3.8/site-packages/aqt/__init__.py", line 400, in run
    _run()
  File "/snap/anki-woodrow/35/lib/python3.8/site-packages/aqt/__init__.py", line 443, in _run
    pmLoadResult = pm.setupMeta()
  File "/snap/anki-woodrow/35/lib/python3.8/site-packages/aqt/profiles.py", line 91, in setupMeta
    res = self._loadMeta()
  File "/snap/anki-woodrow/35/lib/python3.8/site-packages/aqt/profiles.py", line 464, in _loadMeta
    traceback.print_stack()
resetting corrupt _global
Invalid MIT-MAGIC-COOKIE-1 keyQt warning: could not connect to display :0.0 
Qt info: Could not load the Qt platform plugin "xcb" in "" even though it was found. 
Qt fatal: This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, webgl, xcb.
 
fish: “env BAMF_DESKTOP_FILE_HINT=/var…” terminated by signal SIGABRT (Abort)


Try to open ANKI installed with flatpak:


> flatpak run net.ankiweb.Anki
Invalid MIT-MAGIC-COOKIE-1 keyQt warning: could not connect to display :99.0 
Qt info: Could not load the Qt platform plugin "xcb" in "" even though it was found. 
Qt fatal: This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, webgl, xcb.

Temp Fix:

App (at least for flatpak) work normally after deleting Xauthority in the home directory.


rm .Xauthority
sudo shutdown -r now

I do not know the programs you try to use (and the naming is confusing, is it ANKI, Anki or anki?).
But the messages about display=0:0 and MIT-MAGIC-COOKIE point to a program that runs outside a desktop, but wants to open a window (or do some other action) on that desktop.

It’s all small caps: anki

Apps running from a controlled or separate environment is one of the pulls of using flatpak or snap I guess. I don’t have deep knowledge in x.org or stuff, sorry. I just want to know a way to run apps installed from flatpak or snapstore.

Issue seems to be XFCE.

I don’t face this problem anymore after switching to LxQt.