probonopd / linuxdeployqt

Makes Linux applications self-contained by copying in the libraries and plugins that the application uses, and optionally generates an AppImage. Can be used for Qt and other applications
Other
2.18k stars 407 forks source link

Mageia specifies custom QT_PLUGIN_PATH, uses system libs #416

Open hcorion opened 4 years ago

hcorion commented 4 years ago

Our AppImage over at RPCS3 has stopped working with Mageia. After some snooping around Mageia's Qt package I found out that mageia sets QT_PLUGIN_PATH to /usr/lib64/qt5/plugins:/usr/lib64/qt5/plugins/kcms:. This caused Qt to load the system bearer libs, which are at 5.12.x, instead of our bundled Qt, which is at 5.14.x, which caused a deadlock and made our application not show anything.

Relevant RPCS3-side issue here: https://github.com/RPCS3/rpcs3/issues/6986

You can download our AppImages via: curl -JLO https://rpcs3.net/latest-appimage RPCS3 AppImage Deploy script: https://github.com/RPCS3/rpcs3/blob/master/.travis/deploy-linux.bash Reproduced on Mageia 7 LiveCD. Mageia Qt version: 5.12.2 AppImage Qt version: 5.14.1 (from beineri PPA) AppImage build system: Ubuntu 16.04

probonopd commented 4 years ago

Thanks for reporting this. So far we were not aware of any distributions that set QT_PLUGIN_PATH system-wide. Can you please open an issue with Mageia, and ask them for the reason? Possibly they could move away from doing this once they know that this causes trouble for any applications that ship with a private instance of Qt (not only AppImages).

hcorion commented 4 years ago

Tagging @akien-mga since he had mentioned talking to Mageia's Qt packagers.

akien-mga commented 4 years ago

I'm looking at it with Mageia packagers to figure out why we define it and if we can do without.

Mageia also seems to define QTDIR5, but I don't know if this one has influence on running bundled Qt libraries. Here's the culprit:

$ cat /etc/profile.d/60qt5.sh 
#!/bin/bash
QTDIR5="/usr/lib64/qt5" ; export QTDIR5 ;

[ -z $QT5DOCDIR ] && export QT5DOCDIR=/usr/share/doc/qt5

if [ -z $(echo $PATH | grep "/usr/lib64/qt5/bin") ]; then
    PATH=${PATH}:/usr/lib64/qt5/bin
    export PATH
fi

# Set the QT_PLUGIN_PATH environment variable
if [ -z $(echo $QT_PLUGIN_PATH | grep "kcms") ]; then
    QT_PLUGIN_PATH="/usr/lib64/qt5/plugins:/usr/lib64/qt5/plugins/kcms:$QT_PLUGIN_PATH"
    export QT_PLUGIN_PATH
fi

I just found that we have an upstream bug report about it too: https://bugs.mageia.org/show_bug.cgi?id=25038 Which links to Qt 5 docs which specify that one should not define it as system wide.


Still, to be on the safe side, couldn't AppRun or whatever starts the process take care of unsetting any environment variable that might mess with the AppImage? Ideally in a way that would still allow force setting them with QT_PLUGIN_PATH=/foo/bar ./myapp.AppImage for debugging.

probonopd commented 4 years ago

I just found that we have an upstream bug report about it too: https://bugs.mageia.org/show_bug.cgi?id=25038 Which links to Qt 5 docs which specify that one should not define it as system wide.

Thank you very much!

Still, to be on the safe side, couldn't AppRun or whatever starts the process take care of unsetting any environment variable that might mess with the AppImage?

You could remove the AppRun symlink and replace it by e.g., a bash script that would unset all offending variables and then exec the main payload binary.

OlivierLDff commented 3 years ago

Hello, any hint on how to replace the AppRun? I'm using the command linuxdeployqt -appimage

probonopd commented 3 years ago

Just put your own AppRun into the AppDir before you run that command.

OlivierLDff commented 3 years ago

Thank, i followed the wiki. Ended up with something like that:

#!/bin/bash
HERE="$(dirname "$(readlink -f "${0}")")"
export LD_LIBRARY_PATH=""
export QT_PLUGIN_PATH=""
export QML2_IMPORT_PATH=""
exec "${HERE}/usr/bin/QaterialGallery" "$@"

I wrapped it into a cmake function https://github.com/OlivierLDff/QtLinuxCMake

hcorion commented 3 years ago

I'm looking at it with Mageia packagers to figure out why we define it and if we can do without.

It's been a while, what's the status on this issue @akien-mga ? Is this something that Mageia is still looking to fix?

probonopd commented 3 years ago

@hcorion maybe it is best to open an issue with Mageia. I don't think we can do much from the AppImage side?

akien-mga commented 3 years ago

There's already an issue in the Mageia bug tracker, which is fixed for the upcoming 8 release: https://bugs.mageia.org/show_bug.cgi?id=25038

That being said, other distros or even users might still end up in situations where they have QT_PLUGIN_PATH defined in the environment, and IMO if AppImages are meant to be self-contained, they should explicitly ignore it (e.g. unset it in the environment they run in).

For example someone might have a custom Qt install for development purposes with QT_PLUGIN_PATH set, which would prevent them from using Qt AppImages.

trmdi commented 3 years ago

Just put your own AppRun into the AppDir before you run that command.

Any hint why I did that but it still be overwritten?

[ 237s] Keeping existing AppRun

Edit: found it, you have to chmod 755 it.