Bugs in `kpackagetool6`, or user error?

I’m having a strange issue with kpackagetool6 where it will install a KWin script (and the KWin script works) but then the same tool fails to remove/uninstall that very same KWin script from the same folder, with an error like this:

kf.package: Could not find required file "mainscript" for package "/home/cjbottaro/.local/share/kwin/scripts/" should be QList("code/main.js")
kf.package: Could not find required file "mainscript" for package "/usr/share/kwin/scripts/" should be QList("code/main.js")
Error: Plugin  is not installed.

The KWin script in question is here in this development branch of my fork of a repo:

There’s an install script and an uninstall script, they just automate issuing the kpackagetool command appropriate for the KDE version on the system. Ultimately it will just issue a command like this:

kpackagetool6 --type=KWin/Script --install .

The error is coming directly from kpackagetool6, since it appears when I run the tool manually without using the uninstall script.

The KWin script itself is compatible with both Plasma 5 and 6 and this has been tested in multiple virtual machines with different distros using Plasma 5 and 6. The metadata.json file was updated with the line needed to make it Plasma 6 compatible:

"KPackageStructure": "KWin/Script",

But another user trying to install the same KWin script keeps getting this kind of error, which I haven’t run into myself in testing multiple distros:

KPackageStructure of KPluginMetaData(pluginId:"applicationswitcher", fileName: "/home/cjbottaro/.local/share/kwin/scripts/applicationswitcher/metadata.json") does not match requested format "KWin/Script"

I’d appreciate any insight someone can shed on whether any of this is actually caused by a bug or bugs of some kind in kpackagetool6, or some kind of remaining incompatibility in the KWin script or its metadata file. Searching for parts of the error message brought up nothing relevant online, or even here in this forum.

Why would the tool have an error when uninstalling the KWin script, but not have that same error when installing it, from the same folder, if it’s not a bug?

Installing from the GUI via the kwinscript file that is now in the repo has worked for me, and when that method or the install script works (it’s always worked for me) the KWin script works great. I can also activate/deactivate and remove the KWin script through the KWin Scripts settings panel with no apparent issue or error message. It’s only the terminal command that’s giving me this error.

Note that the syntax for installing and removing is different.

When removing you need to pass the name of the package, not a path.

i.e. you want kpackagetool6 --type=KWin/Script --remove applicationswitcher

1 Like

That does seem to fix the issue, but I find myself very ambivalent about the fact that the response was marked as the solution almost immediately, before I had a chance to see the message and the time to test it and return here to confirm that in my own words.

If I was running a forum I would have a policy in place that nobody but the OP could mark a response as the solution for a more respectful 72 hours. Posters can’t always get back and respond immediately, and marking a solution without waiting for their feedback removes any sense of agency from the original poster.

(This is going to seem pretty silly if I’m actually the only one who could mark it as a solution, but I have no knowledge of having done that, even accidentally.)

Anywho, @nicolasfella, thank you for pointing out the solution that didn’t occur to me due to the fact that I hadn’t run into this issue before.

I still find it logical that the tool should be capable of grabbing the script name from the metadata file in the given path, just like the install command does, and then taking that script name and uninstalling it from the usual location (where the same tool installed it). But I will modify the script to use the correct syntax.

Still don’t know what the problem is with the other error message about it not being in the right format, or how to replicate it. I’ve never seen it in my own testing environments since putting that package structure line in the metadata file to satisfy Plasma 6. If anyone reading this has a clue about that…