Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Qt applications fail due to xcb plugin mismatch #24256

Closed
lheckemann opened this issue Mar 23, 2017 · 26 comments
Closed

Qt applications fail due to xcb plugin mismatch #24256

lheckemann opened this issue Mar 23, 2017 · 26 comments

Comments

@lheckemann
Copy link
Member

Issue description

% nix-shell -p openshot-qt

[nix-shell:~]$ openshot-qt
Loaded modules from current directory: /nix/store/0r6czdfcgfwqgar2sbz5zhrbysrmkn80-openshot-qt-2.1.0/lib/python3.5/site-packages
      launch:INFO ------------------------------------------------
      launch:INFO    OpenShot (version 2.1.0)
      launch:INFO ------------------------------------------------
This application failed to start because it could not find or load the Qt platform plugin "xcb"
in "".

Available platform plugins are: minimal, offscreen, xcb.

Reinstalling the application may fix this problem.
Aborted

[nix-shell:~]$

Technical details

  • System: 17.03beta320.ade5837 (Gorilla)
  • Nix version: nix-env (Nix) 1.11.7
  • Nixpkgs version: "17.03beta617.f3a9ccc"
@lheckemann
Copy link
Member Author

Works fine when installed using nix-env -iA nixos.openshot-qt, but both should be possible, right?

@AndersonTorres
Copy link
Member

AndersonTorres commented Mar 24, 2017

Incidentally there is a new version of openshot: #22710

(edited a typo, many thanks @lheckemann !)

@lheckemann
Copy link
Member Author

lheckemann commented Mar 24, 2017

Wrong issue number? I guess you meant #22710

@edolstra
Copy link
Member

edolstra commented Apr 3, 2017

I have the same problem with krita (installed via nix-env):

$ krita
This application failed to start because it could not find or load the Qt platform plugin "xcb"
in "".

Available platform plugins are: minimal, offscreen, xcb.

Reinstalling the application may fix this problem.
Aborted

Installing it via environment.systemPackages does work.

strace shows the following:

open("/run/current-system/sw/lib/qt5/plugins/platforms", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 3
open("/nix/store/32s4bd5mficwpp6064s5rvkpvhzycbkn-qtbase-5.6.2/lib/qt5/plugins/platforms/libqxcb.so", O_RDONLY|O_CLOEXEC) = 3
open("/nix/store/96xragmk6ap2y988qpw50ck7qwfg511j-qtbase-5.7.1/lib/qt5/plugins/platforms/libqxcb.so", O_RDONLY|O_CLOEXEC) = 3

So it's opening two mismatching versions of libqxcb.so, where one is probably discovered via /run/current-system/sw/lib/qt5/plugins/platforms.

@edolstra edolstra changed the title openshot-qt does not start in nix-shell Qt applications fail due to xcb plugin mismatch Apr 3, 2017
@abbradar
Copy link
Member

abbradar commented Apr 4, 2017

Related discussion: #24133

For now one should remove everything that installs Qt plugins (not input ones, they are good) from their environment to fix this -- usually that's qtbase, qtEnv or other Qt packages.

cc @ttuegel

@ttuegel
Copy link
Member

ttuegel commented Apr 8, 2017

I am working on making Qt packages entirely insensitive to their environment.

@edolstra
Copy link
Member

@ttuegel What would be the implications of that? Isn't the plugin mechanism necessary for certain things (like picking up the open dialog box of the desktop environment, theming etc.)?

@ttuegel
Copy link
Member

ttuegel commented Apr 10, 2017

Isn't the plugin mechanism necessary for certain things (like picking up the open dialog box of the desktop environment, theming etc.)?

Right now, I have patched our Qt libraries to go spelunking through NIX_PROFILES in addition to QT_PLUGIN_PATH. I'm not going to remove plugin support, I'm just going to stop going through NIX_PROFILES looking for every possible plugin. 😃 All the desktop integration and theming plugins are currently provided by Qt or KDE anyway, but QT_PLUGIN_PATH will still work should it be necessary.

@glaebhoerl
Copy link
Contributor

glaebhoerl commented May 5, 2017

FWIW if anyone wants a quick and ugly hack to just get an application (in my case kolourpaint) to hopefully start without having to remove or reinstall a bunch of packages:

$ ls /nix/store/*qtbase*/lib/qt5/plugins/platforms/libqxcb.so
/nix/store/0igx2hwicb18di1mx65qh3jrpypvc40a-qtbase-5.6.1-1/lib/qt5/plugins/platforms/libqxcb.so 
/nix/store/9kmi6a4pba9g45wr4c1ny5kasc70jbx9-qtbase-5.6.2/lib/qt5/plugins/platforms/libqxcb.so
/nix/store/3qz77v287y42s3a9l1745551idfcdflr-qtbase-5.8.0/lib/qt5/plugins/platforms/libqxcb.so    
/nix/store/f2680a9j60qi724k7dgphxamlqsq933x-qtbase-5.6.1-1/lib/qt5/plugins/platforms/libqxcb.so

(choose the one that seems appropriate, or just trial and error)

$ NIX_PROFILES=/nix/store/3qz77v287y42s3a9l1745551idfcdflr-qtbase-5.8.0 kolourpaint

(May or may not fail for applications with more complicated dependencies than kolourpaint, did not try.)

@glaebhoerl
Copy link
Contributor

...hm. I'm not 100% sure if this issue is the culprit, but I rebooted and KDE itself failed to start (error message something like "core shell components could not be found, this is a packaging problem, contact your distro"). I did nix-env -e kolourpaint and rebooted again and then it worked.

@ttuegel
Copy link
Member

ttuegel commented May 10, 2017

This is fixed in master: Qt applications know about the QPA plugins they are built with.

@CMCDragonkai
Copy link
Member

@ttuegel I think I'm getting this error at #27790 is there quick fix for people still on 17.03? @glaebhoerl 's trick did not work for me.

@edolstra
Copy link
Member

@ttuegel I still this error when running 17.09-based Qt packages on NixOS 17.03 (e.g. Krita or Tribler). For Tribler, I added this line to the wrapper:

        --set QT_QPA_PLATFORM_PLUGIN_PATH ${qt5.qtbase.bin}/lib/qt-*/plugins/platforms \

which fixes it. Is that the recommended solution?

edolstra added a commit that referenced this issue Sep 10, 2017
Also, fix the xcb plugin error
(#24256) and add service-identity which is a required dependency now.
@CMCDragonkai
Copy link
Member

CMCDragonkai commented Sep 10, 2017

@edolstra Would that flag be relevant to other QT apps as well like #27790

@ttuegel
Copy link
Member

ttuegel commented Sep 10, 2017

For Tribler, I added this line to the wrapper which fixes it. Is that the recommended solution?

I believe setting that variable in the wrapper will break the application under KDE.

It should not be necessary for you to do anything. If it is, then there is a bug I need to fix in our modified Qt plugin loader. Just to check, you have the package installed in environment.systemPackages or by nix-env, right?

@edolstra
Copy link
Member

@ttuegel I was running it as ./result/bin/tribler (so not installed at all).

@ttuegel
Copy link
Member

ttuegel commented Sep 10, 2017

I was running it as ./result/bin/tribler (so not installed at all).

Unfortunately, that is not expected to work. I don't know how to make programs work from the store while also integrating correctly into desktop environments like KDE or LXDE. (This is a really terrible trade-off and I will entertain any suggestion to fix it.) A work-around is to set QT_QPA_PLATFORM_PLUGIN_PATH in shellHook so that at least nix-shell will work.

fpletz pushed a commit that referenced this issue Sep 10, 2017
Also, fix the xcb plugin error
(#24256) and add service-identity which is a required dependency now.

(cherry picked from commit bcd382f)
@jirkadanek
Copy link
Member

What helped me was either to 1) declare the application in /etc/nixos/configuration.nix 2) run nix-env -u --leq, the doc says for this parameter

In addition to upgrading to newer versions, also “upgrade” to derivations that have the same version. Version are not a unique identification of a derivation, so there may be many derivations that have the same version. This flag may be useful to force “synchronisation” between the installed and available derivations. -- https://nixos.org/releases/nix/nix-1.7/manual/#sec-nix-env

@jluttine
Copy link
Member

jluttine commented May 9, 2018

FWIW, I'll add a comment how I fixed this in my case. I ran the failing command with LD_DEBUG=libs some_failing_command and then read from the last few lines what library it failed to find. Then added that to the environment and repeat until the command succeeds. For instance, in my case, adding xlibs.libX11 and xlibs.libXi to the environment solved the issue.

Background: I have FHS user env for Conda and when I launched IPython (ipython --pylabs) installed by Conda, I got the error: This application failed to start because it could not find or load the Qt platform plugin "xcb" in "". So I just needed to add all relevant libraries to this FHS user env. This is probably very different scenario than the OP (or others) had, but just thought I'd share this here in case someone has a similar issue as I did and looks for help here.

@aakropotkin
Copy link
Contributor

Hey I was just struggling with this for a few hours trying to run VirtualBox.
This has some obvious flaws that will not make this a great solution for everybody; but if you're in a bind you can give this a shot.

My fix was :

# In `configuration.nix`
{ config, lib, pkgs, options, ... }:
{
  virtualisation.virtualbox.host.enable = true;
  environment.pathsToLink = ["${pkgs.xorg.libxcb}/lib/"];
}

@timbertson
Copy link
Contributor

My previous workaround of exporting QT_QPA_PLATFORM_PLUGIN_PATH in my shell caused my (fedora system installed) vlc to segfault on startup. So I'd definitely vote for qt apps to be self-contained rather than integrating with the desktop, if this is the outcome.

nh2 added a commit to r-ryantm/nixpkgs that referenced this issue Jan 12, 2020
Fixes error

    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.

See NixOS#24256.
@jmercouris
Copy link

I just upgraded to 20.09 and am running into this issue with my KDE applications. How to fix?

@fadenb
Copy link
Contributor

fadenb commented Nov 11, 2020

Same here, experiencing this since upgrading to 20.09.
In my case, electrum is installed system wide.

→ electrum                                                                                                                                                                        ~
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

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

[1]    6077 abort (core dumped)  electrum

@bhipple
Copy link
Contributor

bhipple commented Nov 15, 2020

Perhaps try upgrading everything you have imperatively installed via nix-env? You may have an old ver in your ~/.nix-profile and a new ver on the system.

nix-env --upgrade

@jmercouris
Copy link

I have installed nothing imperatively.

@Luz
Copy link
Member

Luz commented Sep 18, 2023

I have not found my desired solution in this thread, but in that other one. So I'd like to link it to here, in case anyone else is stumbling upon this.
I suggest to add the following line to the nix-shell file (in my case to a default.nix):
QT_QPA_PLATFORM_PLUGIN_PATH="${qt5.qtbase.bin}/lib/qt-${qt5.qtbase.version}/plugins";

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests