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

electrum: Add QT_QPA_PLATFORM_PLUGIN_PATH #33146

Closed
wants to merge 1 commit into from
Closed

Conversation

k0001
Copy link
Contributor

@k0001 k0001 commented Dec 28, 2017

Motivation for this change

This fixes an error that prevents the program from starting:

This application failed to start because it could not find or load the Qt platform plugin

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option build-use-sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.

This fixes an error that prevents the program from starting:

 "This application failed to start because it could
  not find or load the Qt platform plugin"
@k0001
Copy link
Contributor Author

k0001 commented Dec 28, 2017

cc @joachifm

@joachifm
Copy link
Contributor

Thank you but I've decided against doing this: see e.g., #31470 (comment) and #32642 (comment)

@k0001
Copy link
Contributor Author

k0001 commented Dec 29, 2017

@joachifm the comments claim that this is not a problem one NixOS. However, I am running NixOS, did install the package using nix-env, and still I see this problem unless I correct it as I am doing in this patch. Clearly there's something else wrong.

Grepping for QT_QPA_PLATFORM_PLUGIN_PATH in nixpkgs suggests a couple other packages doing this as well.

@joachifm
Copy link
Contributor

cc @ttuegel

@joachifm
Copy link
Contributor

joachifm commented Dec 29, 2017

Grepping for QT_QPA_PLATFORM_PLUGIN_PATH in nixpkgs suggests a couple other packages doing this as well.

I see, but note that many anti-patterns propagate via copy-n-paste. I'll defer to the qt maintainers on this one.

@ttuegel
Copy link
Member

ttuegel commented Dec 29, 2017

Grepping for QT_QPA_PLATFORM_PLUGIN_PATH in nixpkgs suggests a couple other packages doing this as well.

Please don't do this; the result will be an application that may work under some desktop environments but not others.

Clearly there's something else wrong.

To begin with: What version of NixOS are you running? What version of Qt is installed in your system profile? What version of Qt is installed in your user profile?

@k0001
Copy link
Contributor Author

k0001 commented Dec 29, 2017

@ttuegel @joachifm thanks. I am running NixOS 17.09. I have KDE Plasma 5 as my desktop environment installed in my system profile, and that's about as much QT I have installed explicitly. Do I need to install something else?

@lukateras
Copy link
Member

lukateras commented Dec 30, 2017

@ttuegel: Sorry to piggyback on this, but I have the same problem with Krita, where I can't run it on Travis CI (required for build to convert .kra files to .png) without setting QT_QPA_PLATFORM_PLUGIN_PATH in a wrapper: https://github.com/yegortimoshenko/zhenya-slim-theme/blob/8c3f85a394024398767ad1d09fff29ae21084d05/default.nix

I would really like to drop it from the build system and move it into Nixpkgs. It can be reproduced on any Linux machine that has Nix installed: nix-shell -p krita --pure --run krita. I get:

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

What is the current way around this? Setting it in shellHook? Can it be fixed for all Qt apps?

@ttuegel
Copy link
Member

ttuegel commented Dec 31, 2017

What is the current way around this? Setting it in shellHook? Can it be fixed for all Qt apps?

Yes, you could set it in shellHook. Ultimately, though, I think I just need to go in and revert the changes that made Qt applications sensitive to their environment: things were broken then, but I got fewer complaints and maintainers weren't piling broken workarounds onto their packages.

@lukateras
Copy link
Member

If revert will result in breakage, I'd rather have Krita broken in nix-shell rather than anywhere else.

@ttuegel
Copy link
Member

ttuegel commented Dec 31, 2017

If revert will result in breakage, I'd rather have Krita broken in nix-shell rather than anywhere else.

The current situation is: Qt applications are broken in nix-shell, but work if the user installs them following the instructions. But integration plugins (themes, non-standard input methods, etc.) work! Of course, that hardly matters if the application doesn't run. And if the maintainer sets QT_QPA_PLATFORM_PLUGIN_PATH, integration probably breaks anyway.

The alternative is: Qt applications work everywhere, but integration plugins (themes, input methods) may be broken if the package maintainer and user don't follow instructions. This is essentially the state of affairs with GTK 3, and everybody seems happy enough with that.

In that light, the alternative seems strictly less broken than the current state of affairs, and anyway I cannot keep fielding the same bug reports over and over and over.

@joachifm joachifm closed this Jan 21, 2018
@k0001
Copy link
Contributor Author

k0001 commented Feb 7, 2018

@ttuegel @joachifm without this change, what are the instructions for running QT apps that have this problem without requiring some nix-shell wrapping for them? I agree with @yegortimoshenko that I'd rather have this broken in nix-shell than anywhere else, it's quite sad that these applications can't be installed through nix-env anymore.

@k0001 k0001 mentioned this pull request Feb 7, 2018
8 tasks
@ttuegel
Copy link
Member

ttuegel commented Feb 8, 2018

I agree with @yegortimoshenko that I'd rather have this broken in nix-shell than anywhere else, it's quite sad that these applications can't be installed through nix-env anymore.

I don't understand; Qt applications do work in nix-env, they are broken in nix-shell.

@k0001
Copy link
Contributor Author

k0001 commented Feb 8, 2018

@ttuegel check this out:

k@z1 ~ $ env |grep QT
QTWEBKIT_PLUGIN_PATH=/etc/per-user-pkgs/k/lib/mozilla/plugins/:/home/k/.nix-profile/lib/mozilla/plugins/:/nix/var/nix/profiles/default/lib/mozilla/plugins/:/run/current-system/sw/lib/mozilla/plugins/

QT_PLUGIN_PATH=/etc/per-user-pkgs/k/lib/qt4/plugins:/etc/per-user-pkgs/k/lib/kde4/plugins:/home/k/.nix-profile/lib/qt4/plugins:/home/k/.nix-profile/lib/kde4/plugins:/nix/var/nix/profiles/default/lib/qt4/plugins:/nix/var/nix/profiles/default/lib/kde4/plugins:/run/current-system/sw/lib/qt4/plugins:/run/current-system/sw/lib/kde4/plugins

k@z1 ~ $ nix-env -iA nixpkgs-unstable.electrum
installing ‘electrum-3.0.5’

k@z1 ~ $ electrum
This application failed to start because it could not find or load the Qt platform plugin "xcb"
in "".

Reinstalling the application may fix this problem.
Aborted

@k0001
Copy link
Contributor Author

k0001 commented Feb 8, 2018

@ttuegel could it be that you already have QT_QPA_PLATFORM_PLUGIN_PATH defined in your environment somehow, and that's why it's working for you? If so, is it a good idea to have that environment variable defined with the same value for all QT applications, rather than defining it per package? I would guess no…

@joachifm
Copy link
Contributor

joachifm commented Feb 8, 2018

Fwiw, on non-NixOS hosts I've had to set those variables and LD_LIBRARY_PATH myself to run QT5 apps from nixpkgs (via nix-env or otherwise).

@k0001
Copy link
Contributor Author

k0001 commented Feb 8, 2018

I just tried adding this to my configuration.nix:

environment.variables.QT_QPA_PLATFORM_PLUGIN_PATH = 
    "${pkgs.qt5.qtbase.bin}/lib/qt-${pkgs.qt5.qtbase.qtCompatVersion}/plugins/platforms";

However, electrum still complaints about not being able to find the necessary plugin. Presumably because I'm running NixOS 17.09, whose pkgs.qt5 is a different version from the one in nixpkgs unstable where I'm getting electrum from (which makes total sense, but also means that this QT program still doesn't run unless I override QT_QPA_PLATFORM_PLUGIN_PATH locally as originally suggested in this pull-request 😢).

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

Successfully merging this pull request may close these issues.

None yet

5 participants