inventree / inventree-brother-plugin

Label printing plugin for Brother series printers
MIT License
16 stars 12 forks source link

Error "Plugin registry has no record of plugin 'brother'" #35

Closed simonkuehling closed 5 months ago

simonkuehling commented 5 months ago

Hi,

after a recent InvenTree update from https://github.com/inventree/InvenTree/commit/7d5ff1d5bdb35b66c340378f7828dc419320e2c4 (28. August 2023) to the current latest docker image (https://github.com/inventree/InvenTree/commit/6abd33f060ed471526ca8d6ce99acb12e2ecd944) I found that my brother label plugin stopped working and throws an error suggesting that the brother plugin isn't installed:

inventree-worker    | Plugin registry has no record of plugin 'brother'
inventree-worker    | Could not find matching plugin for 'brother'

Since the plugin is active and visible throughout the admin and settings pages and is listed in the label printing dialog as well, I am stuck what went wrong here - any idea?

Inventree version info:

# Version Information:
InvenTree-Version: 0.15.0 dev
Django Version: 4.2.10
Commit Hash: 6abd33f
Commit Date: 2024-03-14

Database: postgresql
Debug-Mode: False
Deployed using Docker: True
Platform: Linux-6.1.0-rpi7-rpi-v8-aarch64-with
Installer: DOC

Active plugins: [{'name': 'InvenTreeBarcode', 'slug': 'inventreebarcode', 'version': '2.0.0'}, {'name': 'InvenTreeCoreNotificationsPlugin', 'slug': 'inventreecorenotificationsplugin', 'version': '1.0.0'}, {'name': 'InvenTreeCurrencyExchange', 'slug': 'inventreecurrencyexchange', 'version': '1.0.0'}, {'name': 'InvenTreeLabel', 'slug': 'inventreelabel', 'version': '1.0.0'}, {'name': 'InvenTreeLabelMachine', 'slug': 'inventreelabelmachine', 'version': '1.0.0'}, {'name': 'InvenTreeLabelSheet', 'slug': 'inventreelabelsheet', 'version': '1.0.0'}, {'name': 'DigiKeyPlugin', 'slug': 'digikeyplugin', 'version': '1.0.0'}, {'name': 'LCSCPlugin', 'slug': 'lcscplugin', 'version': '1.0.0'}, {'name': 'MouserPlugin', 'slug': 'mouserplugin', 'version': '1.0.0'}, {'name': 'TMEPlugin', 'slug': 'tmeplugin', 'version': '1.0.0'}, {'name': 'IPNAutoGenerator', 'slug': 'ipnautogenerator', 'version': None}, {'name': 'OrderNotesTemplates', 'slug': 'ordernotestemplates', 'version': None}, {'name': 'Brother Labels', 'slug': 'brother', 'version': '0.8.2'}]

Thanks for your help!

SchrodingersGat commented 5 months ago

Are there any "plugin loading errors" in your plugin settings window?

SchrodingersGat commented 5 months ago

Also, what version of inventree-brother-plugin are you running?

simonkuehling commented 5 months ago

There are no errors that I can see anywhere, unfortunately... The plugin is installed via the <data>/plugins.txt file and is currently running on version 0.8.2. It was initially installed in the old installation though and just gut upgraded during the InvenTree upgrade as well - have there been any major changes to the plugin registry in the last months?

It is odd that the settings page shows the plugin as active and its configuration page has still all the parameters correctly set like it has been before - also the Key is displayed as brother as expected...

If I would want to try de-installing the plugin and re-installing afterwards - how would I go for it to ensure there are no traces left before the new install - I guess removing it from plugins.txt, running invoke update, putting it back in and invoke update again?

SchrodingersGat commented 5 months ago

You should ensure that you stop and then restart the worker process - perhaps it has not correctly reloaded the plugins, but the server process has?

You can also check that both processes (worker / server) are actually running the same versions:

docker compose run --rm Inventree-worker invoke version
docker compose run --rm Inventree-server invoke version
simonkuehling commented 5 months ago

both are running the same version:

InvenTree - inventree.org
The Open-Source Inventory Management System

Installation paths:
Base        /home/inventree
Config      /home/inventree/data/config.yaml
Media       /home/inventree/data/media
Static      /home/inventree/data/static

Versions:
Python      3.11.8
Django      4.2.10
InvenTree   0.15.0 dev
API         182
Node        N/A
Yarn        N/A

Commit hash:6abd33f
Commit date:2024-03-14

stopping + restarting the worker process did not help unfortunately...

SchrodingersGat commented 5 months ago

@simonkuehling I have just tested a fresh setup with inventree-brother-plugin and it does not hit this error. It attempts to print (although I don't have a test printer so it throws a connection error, but still)...

If you are able to provide any more detailed traceback or error information that would be very helpful

simonkuehling commented 5 months ago

Sorry, I don‘t know why I have not switched to DEBUG logging before - that reveals something at least: Seems like the worker processes do not load the brother plugin:

IMG_8312

Two local plugins from data/plugins/ are discovered and loaded correctly - just not the one from data/plugins.txt (which is loaded by inventree-server though)…

simonkuehling commented 5 months ago

Here is the part of the log where inventree-server is loading the plugins (including the brother label plugin):

IMG_8337

simonkuehling commented 5 months ago

One more info - seems like the pip package is actually not installed in the worker process for some reason:

IMG_8356

SchrodingersGat commented 5 months ago

@simonkuehling turns out there was a critical bug which prevents any plugins from being loaded by the background worker. Fix incoming - https://github.com/inventree/InvenTree/pull/6733

I will push out a stable patch with this fix

simonkuehling commented 5 months ago

Hmm, my custom plugins have been working fine in the worker process throughout this though (loaded from data/plugins/)…

I just updated to 7905c55 to check your changes - but the brother plugin still isn‘t available to the worker… (i did run „docker-compose run —rm inventree-server invoke plugins“)

Since you checked with a fresh setup and it worked - what could possibly be skewed on my side to prevent its discovery? I am running the images from dockerhub - so I guess it has to be something with my database or my data directory maybe? (Just guessing blindly here… 🤷‍♂️)

SchrodingersGat commented 5 months ago

Hmm, my custom plugins have been working fine in the worker process throughout this though (loaded from data/plugins/)…

The difference here is that you are installing the brother labels plugin via plugins.txt (while your custom plugins exist in a local directory) Each time you restart the container, that needs to be re-installed. Which is not happening with the background worker due container due to the bug discussed in #6733

simonkuehling commented 5 months ago

Oh, got it - for some embarrassing reason I have read that you pushed a commit, when it is clearly still an unmerged PR 🤦‍♂️