Repository navigation
Description
In commit 9ea3e37, the setup-hook for qtbase adds itself to propagated-user-env-packages. Normally this isn't a big problem and just cluttering up the system path, but if there are mixed versions of the Qt libraries, things can get pretty nasty when stuff is loaded at runtime.
And that's what happens if you add a random Qt 5.5 program into environment.systemPackages with KDE 5 enabled:
$ nix-store -qR /run/current-system/sw | grep qtbase
/nix/store/kfj94grdfkyn1ryd8kj7vdx470sbp1kb-qtbase-5.6.0
/nix/store/ndhbfkanyg46y8phw9jv93cwg1fm7ryr-qtbase-5.6.0-dev
/nix/store/bx34kkw8yjkh70515hy0wximjvx2dh00-qtbase-5.5.1
/nix/store/yrxzmr1ck2c17znq0knddgllznzq8d10-qtbase-5.5.1-devIn theory, this shouldn't be a problem, but it turns out that KDE won't start with this, because it's trying to load the libraries at runtime from the system path.
This is what happens during KDE startup (reindented to save horizontal space):
/nix/store/9mpqvbgg7slw3hal78ryrp80xhq8kd8k-plasma-workspace-5.6.4/bin/ksplashqml:
symbol lookup error: /nix/store/bx34kkw8yjkh70515hy0wximjvx2dh00-qtbase-5.5.1/lib/libQt5XcbQpa.so.5:
undefined symbol: _ZN22QWindowSystemInterface19registerTouchDeviceEP12QTouchDevice
The plasma-workspace package only lists qtbase-5.6 in its dependencies and the ksplashqml binary is only linked against qtbase-5.6 as well:
$ nix-store -qR /nix/store/9mpqvbgg7slw3hal78ryrp80xhq8kd8k-plasma-workspace-5.6.4 | grep qtbase
/nix/store/kfj94grdfkyn1ryd8kj7vdx470sbp1kb-qtbase-5.6.0
/nix/store/ndhbfkanyg46y8phw9jv93cwg1fm7ryr-qtbase-5.6.0-devSo adding any Qt 5.5 program to environment.systemPackages with current KDE 5 will break KDE as of 9035827.
I guess we could at least mitigate this by only propagating the plugin stuff into systemPackages (but even that could end up having mixed Qt versions), but I'm neither using KDE nor do I know details about it.
Cc: @ttuegel
Activity
aszlig commentedon May 16, 2016
Also here are the links from the system path for
libQt5XcbQpa:copumpkin commentedon May 16, 2016
Linking to #12575
pkgs/tomahawk: Don't propagate Qt libs to user env
abbradar commentedon May 18, 2016
See also #14937
ttuegel commentedon May 18, 2016
I'm testing a patch for this now.
vcunat commentedon May 18, 2016
/participate
ttuegel commentedon May 19, 2016
The problem here is not actually the Qt libraries themselves because Nix's
RPATHmagic means each Qt program will always load the correct version, i.e. the libraries in the system path do not affect dynamic loading. The actual problem is with Qt's numerous plugins: these are (or can be) loaded from the system path. This would not be a problem if Qt had any notion of plugin versions, but it does not: Qt just loads whatever plugins it thinks it needs and segfaults be damned.I originally approached this by making a limited emulation of
buildEnvfor Qt and KDE programs. Now I realize that is not the right way to go. For one thing,buildEnvalready exists. For another, it's not good enough to extend the plugin path every time an environment gets loaded. Every program must run in its specific, pure environment.So, this is what will happen: Qt 5 programs will stop propagating plugins into the user environment, but they will also absolutely, unconditionally stop working unless the package is made to use
makeQtWrapper(as a consequence of being run in a more restricted environment). KDE 5 still needs all of its packages to live in a single environment (for other reasons). We will have something likekde5Env(based onbuildEnv) and all your KDE 5 packages will have to go in there, or again, they will not work at all.It will take more time for me to patch and document this. This is a very significant change, so I want the documentation especially to be very robust.
abbradar commentedon May 19, 2016
If I understand correctly, this would break Qt support for input methods -- people won't be able to use their method of choice because the plugin won't be loaded. GTK had a similar problem, which was fixed by introducing versioned paths for plugins for GTK2 and GTK3. Maybe we want to go down the same road there (provided it won't be very difficult)?
ttuegel commentedon May 20, 2016
Keep in mind we're talking only about Qt 5; the paths are already versioned between Qt 4 and Qt 5.
Also, this won't break I-Bus support, which is built into Qt 5. Qt upstream would probably also tell you that it's the only input method with their approval, though I recognize this isn't really relevant here.
Qt makes no ABI compatibility guarantees between versions. Even minor versions. Even builds of the same version with different options. So, the only way this could safely work is if plugins went into
$out/lib/qt5/<hash>/plugins. But, there's not just one hash we have to worry about; there's the hash of every package that provides a plugin (which is almost all of the Qt modules).abbradar commentedon May 20, 2016
Oh, it's that bad -- I've supposed that it could be solved with
5.5,5.4etc separation, but it sounds like the things are way worse.I think the only other input method that we support and that may require a separate plugin then (I'm not sure) is Fcitx (see table in #11254). If we can save its support, then it's okay I think.
ericsagnes commentedon May 20, 2016
I just had this issue with qt fcitx plugin not working with qt55 applications.
Dedicated issue:#15569
2 remaining items
ttuegel commentedon May 28, 2016
We could do that. The only thing that should be loaded from
$NIX_PROFILES/lib/qt-5.xis input methods, though; Qt upstream claims that building input methods with the latest available Qt is good enough, in which case all Qt 5 versions could simply load input methods from$NIX_PROFILES/lib/qt5. I think I will try the simpler approach first, but keeping such a patch in mind if we encounter trouble.abbradar commentedon Jun 9, 2016
FWIW, removing
/run/current-system/sw/lib/libQt*from the system path allows me to run Krita (built atop 5.6.1) even though I have it "contaminated" with 5.5's modules. This can serve as a workaround (ugly one because you have to patchnixos/modules/config/system-path.nix).EDIT: with 5.6.1 I need to remove
lib/qt5too. So it's essentially "hack-remove Qt from system path" which would break at least input methods I think. Not recommended.abbradar commentedon Jul 9, 2016
I came up with this derivation to help track down system packages with Qt dependencies:
Paste it to a file and
nix-buildit. Look intoresult. It may be inaccurate w.r.t. multiple outputs but should do a good job in most cases.cc @womfoo
womfoo commentedon Jul 9, 2016
Thanks @abbradar!
qt56.qtbase: don't use propagatedUserEnvPkgs
ttuegel commentedon Jul 16, 2016
The issue should be resolved now. Properly-wrapped Qt packages will use their correct plugin versions. Input methods can still be installed in system-wide or per-user paths.
ericsagnes commentedon Jul 25, 2016
@ttuegel I am not sure if this is related to this, but the way
qt55.fcitx-qt5is built has changed recently.qt55.fctix-qt5is not generating$out/lib/qt5/plugins/*anymore whileqt56.fcitx-qt5still does.I have looked into this and the cause seems to be that the
build/platforminputcontext/cmake_install.cmakegenerated by thebuildPhasefor theqt55version contains wrong path references. (/run/user/1000/...)qt55.fctix-qt5build/platforminputcontext/cmake_install.cmaketo compare with
qt56.fctix-qt5build/platforminputcontext/cmake_install.cmakeericsagnes commentedon Jul 25, 2016
reverting 766ea7c fixes the problem, should I open a new issue?
ttuegel commentedon Jul 25, 2016
No, we should actually stop building
qt55.fcitx-qt5. The Qt 5.6 version will work with Qt 5.5 applications, but not the other way around. Input method plugins should always just be built with the latest Qt we have.ericsagnes commentedon Jul 25, 2016
As far as I can tell,
qt56.fcitx-qt5doesn't work withqutebrowser,calibreand probably other applications usingPyQt.ttuegel commentedon Jul 25, 2016
Of course not, because nothing ever works the way it's supposed to. 😦
Please open a new issue about making input method plugins co-installable. I will see about patching the fcitx builder. We don't want to revert that commit.
ericsagnes commentedon Jul 25, 2016
Thanks, I will open a new issue!
pkgs/tomahawk: Remove Qt propagation workaround
nixos-discourse commentedon Mar 30, 2020
This issue has been mentioned on NixOS Discourse. There might be relevant details there:
https://discourse.nixos.org/t/please-fix-all-packages-which-were-broken-by-the-qt-wrapping-changes/6444/22