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.19k stars 409 forks source link

Skip import: name or path is empty #78

Open probonopd opened 7 years ago

probonopd commented 7 years ago

Fails to deploy cool-retro-term:

export PATH=/tmp/.mount_QtCreator-5.8.0-x86_64/5.8/gcc_64/bin/:$PATH
git clone --recursive https://github.com/Swordfish90/cool-retro-term.git
cd cool-retro-term
qmake && make
mkdir -p appdir/usr/share/appdata appdir/usr/bin
cp packaging/appdata/cool-retro-term.appdata.xml appdir/usr/share/appdata/
cp cool-retro-term appdir/usr/bin/
cp ./cool-retro-term.desktop appdir/
cp ./app/icons/128x128/cool-retro-term.png appdir/
cp -r ./app/qml appdir/usr/
wget -c https://github.com/probonopd/linuxdeployqt/releases/download/continuous/linuxdeployqt-continuous-x86_64.AppImage
chmod a+x linuxdeployqt-continuous-x86_64.AppImage 
./linuxdeployqt-continuous-x86_64.AppImage appdir/usr/bin/cool-retro-term -qmldir=.
export VERSION=$(git rev-list --count HEAD).$(git describe --tags | cut -d - -f 3)
./linuxdeployqt-continuous-x86_64.AppImage appdir/usr/bin/cool-retro-term -qmldir=. -appimage
./Cool_Retro_Term-527.ge48719f-x86_64.AppImage 

# QApplication: invalid style override passed, ignoring it.
# QQmlApplicationEngine failed to load component
# qrc:/main.qml:135 Type TerminalContainer unavailable
# qrc:/TerminalContainer.qml:37 Type PreprocessedTerminal unavailable
# qrc:/PreprocessedTerminal.qml:24 module "QMLTermWidget" is not installed
# 
# Cannot load QML interface
probonopd commented 7 years ago

qml/QMLTermWidget is not deployed automatically. The following manual workaround fixes it:

cp -r qmltermwidget/QMLTermWidget/ appdir/usr/qml/
./linuxdeployqt-continuous-x86_64.AppImage appdir/usr/bin/cool-retro-term -qmldir=. -qmldir=./qmltermwidget/ -appimage

What do I have to do in order to get qml/QMLTermWidget deployed automatically? Other QML imports such as qml/QtQml, qml/QtQuick, qml/QtQuick.2 did get deployed automatically (at least with the second run).

Possibly this is a manifestation of https://github.com/probonopd/linuxdeployqt/issues/25.

probonopd commented 7 years ago

I suspect it has to do with

./linuxdeployqt-continuous-x86_64.AppImage appdir/usr/bin/cool-retro-term -qmldir=. -qmldir=./qmltermwidget/ -appimage -verbose=3 2>&1 | grep QMLTermWidget -C 3

Log: Deploying QML import "QMLTermWidget"
Log: path: ""
Log: type: "module"
Log:   Skip import: name or path is empty
probonopd commented 7 years ago

What adds to the suspicion is this: https://travis-ci.org/probonopd/cool-retro-term/builds/203199838#L935-L977

Log: Deploying QML import "QtQuick.Controls"
Log: path: ""
Log: type: "module"
Log:   Skip import: name or path is empty

Log: Deploying QML import "QtQuick.Dialogs"
Log: path: ""
Log: type: "module"
Log:   Skip import: name or path is empty

Log: Deploying QML import "QtGraphicalEffects"
Log: path: ""
Log: type: "module"
Log:   Skip import: name or path is empty

Log: Deploying QML import "QMLTermWidget"
Log: path: ""
Log: type: "module"
Log:   Skip import: name or path is empty

Resulting in:

me@host:~/test/cool-retro-term$ /home/me/Downloads/cool-retro-term-166.g2f25bd3-x86-64.appimage 
QApplication: invalid style override passed, ignoring it.
QQmlApplicationEngine failed to load component
qrc:/main.qml:24 module "QtGraphicalEffects" is not installed
qrc:/main.qml:23 module "QtQuick.Controls" is not installed
qrc:/main.qml:24 module "QtGraphicalEffects" is not installed
qrc:/main.qml:23 module "QtQuick.Controls" is not installed

Cannot load QML interface
probonopd commented 7 years ago

So whenever we get

Log: path: ""
Log: type: "module"

we should try to figure out the path manually. The heuristic seems to be:

  1. Check if type is "module", otherwise skip
  2. Replace "." in the name with "/" to get the path
  3. Search for that path in the Qt to be bundled, and in any -qmldir (sub)directories
  4. If the path has been found this way, use it in place of the empty path: ""

Do you agree? Any volunteers to implement this?

probonopd commented 7 years ago

https://github.com/probonopd/FeedTheMonkey/blob/patch-1/.travis.yml also suffers from this:

qrc:/qml/main.qml:24 module "Qt.labs.settings" is not installed
qrc:/qml/main.qml:21 module "QtQuick.Controls" is not installed
qrc:/qml/main.qml:23 module "QtQuick.Layouts" is not installed
qrc:/qml/main.qml:22 module "QtQuick.Window" is not installed
qrc:/qml/main.qml:20 module "QtQuick" is not installed

Adding -qmldir=/opt/qt58/qml/ solved that for me.

probonopd commented 7 years ago

Duh, passing in -qmldir=$(readlink -f /opt/qt5*/qml/) fixed it for me. Perhaps we can add code like this to the qmlimportscanner call, something like

    argumentList.append( "-importPath");
    argumentList.append(qtToBeBundledInfo.value("QT_INSTALL_QML "));

Trying this in https://github.com/probonopd/linuxdeployqt/commit/fc571daf7bfb06e63e18aae85e1b134fecdfb99b

probonopd commented 7 years ago

The extra -qmldir=$(readlink -f /opt/qt5*/qml/) is not needed anmore thanks to @afiestas https://github.com/probonopd/linuxdeployqt/commit/ac9e9db2d0a909246ae2bc787a34916f92e085e6

probonopd commented 7 years ago

Current hypothesis is that -qmldir needs to be used properly, then it should work. Reopen if it doesn't.

probonopd commented 6 years ago

https://github.com/probonopd/Hanoi-Towers/blob/patch-1/.travis.yml is also still affected (like lalamachine),

# Log: Deploying QML import "QtQuick.Controls"
# Log: path: ""
# Log: type: "module"
# Log:   Skip import: name or path is empty
probonopd commented 6 years ago

Stupid me; at least for Hanoi-Towers it works when installing qt59quickcontrols qt59quickcontrols2