Repository navigation
Description
Please verify that this bug has NOT been raised before.
- I checked and didn't find a similar issue
Describe the bug*
I am running Inventree in kubernetes and have found a bug with how plugins.txt works.
You don't need to be using kubernetes for this bug, any "one database, multiple distinct python venvs" setup will have this issue.
How I found the bug:
On an existing/running install, I added the mcp plugin so I could quickly test a few things out.
During routine cluster maintenance (drain one node at a time, update, re-join cluster), Inventree was re-instantiated onto a new node and when the new instance came up, the mcp plugin was not loaded.
The database and plugins.txt persist, but the container's Python packages do not.
It took a bit of digging but it looks like the root cause is the previously stored _PLUGIN_FILE_HASH matches the requirements file and returns without checking whether the packages exist in the current Python environment.
The documented container installation behavior suggests that enabling Check Plugins on Startup should handle ephemeral plugin environments but that does not happen in all cases.
After inventree restarts, the plugin is not installed and it shows up as not installed when I visit the /web/settings/admin/plugin/ page.
TL;DR: With Check Plugins on Startup enabled, replacing an InvenTree container can leave configured plugins uninstalled.
It looks like this "shallow check" behavior is new: PR #12776 moved the installer guard from process-local state to a database-backed _PLUGIN_FILE_HASH and added a shared lease.
A database-wide hash cannot establish that packages are installed in every Python environment using the database (web server/core and the worker node(s) ).
Steps to Reproduce
I use podman but I have it aliased to docker; this should be copy/paste / ready to show the issue.
❯ mkdir -p /tmp/inventree-plugin-repro
❯ cd /tmp/inventree-plugin-repro
❯ curl -fsSLO https://raw.githubusercontent.com/inventree/InvenTree/master/contrib/container/docker-compose.yml
❯ curl -fsSLO https://raw.githubusercontent.com/inventree/InvenTree/master/contrib/container/.env
❯ cp .env .envORIG
'.env' -> '.envORIG'
# Make minimal changes
❯ diff .env .envORIG
9c9
< INVENTREE_TAG=1.5.4
---
> INVENTREE_TAG=stable
35c35
< INVENTREE_LOG_LEVEL=INFO
---
> INVENTREE_LOG_LEVEL=WARNINGThen prep for first launch:
❯ docker compose pull inventree-db inventree-cache inventree-server inventree-worker
❯ docker compose up -d --wait inventree-db inventree-cache
[+] Running 3/3
✔ Network inventree_default Created 0.0s
✔ Container inventree-cache Healthy 1.4s
✔ Container inventree-db Healthy 16.9s
❯ docker compose run --rm --no-deps inventree-server invoke update
# <...> This takes ... A WHILE to run for the first time!
Settings cleaned successfullyInstall plugin:
# Sorry for the 1 liner... whitespace breaks it otherwise!
❯ docker compose run --rm --no-deps inventree-server python /home/inventree/src/backend/InvenTree/manage.py shell -c 'from django.conf import settings; from common.models import InvenTreeSetting; InvenTreeSetting.set_setting("PLUGIN_ON_STARTUP", True); settings.PLUGIN_FILE.write_text("inventree-mcp==0.2.2\n"); print("Requirements file:", settings.PLUGIN_FILE)'
# <...>
113 objects imported automatically (use -v 2 for details).
Requirements file: /home/inventree/data/plugins.txtI'll use this script going forward:
❯ cat check-plugins.sh
#!/usr/bin/env bash
set -euo pipefail
if command -v podman >/dev/null 2>&1; then
container_engine=podman
elif command -v docker >/dev/null 2>&1; then
container_engine=docker
else
printf 'Error: neither podman nor docker is available in PATH.\n' >&2
exit 1
fi
if ! "$container_engine" compose version >/dev/null 2>&1; then
printf 'Error: %s compose is not available.\n' "$container_engine" >&2
exit 1
fi
if ! compose_services=$("$container_engine" compose config --services); then
printf 'Error: run this script from your configured Compose directory.\n' >&2
exit 1
fi
if (( $# == 0 )); then
set -- inventree-server inventree-worker
fi
status=0
for service in "$@"; do
if [[ ! "$service" =~ ^[a-zA-Z0-9][a-zA-Z0-9_.-]*$ ]] ||
[[ $'\n'"$compose_services"$'\n' != *$'\n'"$service"$'\n'* ]]; then
printf 'Error: unknown Compose service: %s\n' "$service" >&2
status=1
continue
fi
printf '\nService: %s\n' "$service"
if ! "$container_engine" compose exec -T "$service" python - <<'PY'
import hashlib
import sys
from importlib.metadata import PackageNotFoundError, version
from pathlib import Path
try:
print("inventree-mcp:", version("inventree-mcp"))
except PackageNotFoundError:
print("inventree-mcp: MISSING")
path = Path("/home/inventree/data/plugins.txt")
try:
contents = path.read_bytes()
except OSError as error:
print(f"Error reading {path}: {error}", file=sys.stderr)
sys.exit(1)
print("plugins.txt:", repr(contents.decode("utf-8", errors="replace")))
print("file hash:", hashlib.sha256(contents).hexdigest())
PY
then
printf 'Error: could not complete inspection of %s.\n' "$service" >&2
status=1
fi
done
exit "$status"Then start and do install:
❯ docker compose up -d --wait --wait-timeout 300 inventree-server
❯ ./check-plugins.sh
Service: inventree-server
inventree-mcp: 0.2.2
plugins.txt: 'inventree-mcp==0.2.2\n'
file hash: 03580a9e0cf60dd59ec04bfe1e55100ee2bd252c5acbd3c14ae95ea09bf22e49
Service: inventree-worker
service "inventree-worker" is not running
Error: executing /usr/local/bin/docker-compose exec -T inventree-worker python -: exit status 1
Error: could not complete inspection of inventree-worker.May as well check what's in the DB:
# Note: I use podman, change as needed
❯ printf '%s\n' "SELECT key, value FROM common_inventreesetting WHERE key IN ('PLUGIN_ON_STARTUP', '_PLUGIN_FILE_HASH');" | podman compose exec -T inventree-db sh -c 'exec psql -U "$POSTGRES_USER" -d "$POSTGRES_DB"'
key | value
-------------------+------------------------------------------------------------------
PLUGIN_ON_STARTUP | True
_PLUGIN_FILE_HASH | 03580a9e0cf60dd59ec04bfe1e55100ee2bd252c5acbd3c14ae95ea09bf22e49
(2 rows)Then start up second container and show the issue:
❯ docker compose up -d --wait --wait-timeout 300 inventree-worker
❯ ./check-plugins.sh
Service: inventree-server
inventree-mcp: 0.2.2
plugins.txt: 'inventree-mcp==0.2.2\n'
file hash: 03580a9e0cf60dd59ec04bfe1e55100ee2bd252c5acbd3c14ae95ea09bf22e49
Service: inventree-worker
inventree-mcp: MISSING
plugins.txt: 'inventree-mcp==0.2.2\n'
file hash: 03580a9e0cf60dd59ec04bfe1e55100ee2bd252c5acbd3c14ae95ea09bf22e49And then show how it'll go MISSING in any future container, too:
# This mimics the same thing that k8s does when a workload is migrated or restarted
❯ docker compose up -d --no-deps --force-recreate --wait --wait-timeout 300 inventree-server
# Boom
❯ ./check-plugins.sh
Service: inventree-server
inventree-mcp: MISSING
plugins.txt: 'inventree-mcp==0.2.2\n'
file hash: 03580a9e0cf60dd59ec04bfe1e55100ee2bd252c5acbd3c14ae95ea09bf22e49
Service: inventree-worker
inventree-mcp: MISSING
plugins.txt: 'inventree-mcp==0.2.2\n'
file hash: 03580a9e0cf60dd59ec04bfe1e55100ee2bd252c5acbd3c14ae95ea09bf22e49Expected behaviour
Each Python environment should satisfy the plugin requirements before its service starts, including after container replacement.
Ideally an unchanged requirements file should only skip installation when the current environment already satisfies it.
Deployment Method
Other - added info in Steps to Reproduce
Version Information
InvenTree-Version: 1.5.4
Django Version: 5.2.16
Commit Hash: d2db7b1
Commit Date: 2026-09-09
Commit Branch: null
Database: django.db.backends.postgresql
Debug-Mode: False
Deployed using Docker: True
Platform: Linux-6.8.0-55-generic-x86_64-with-glibc2.41
Installer: DOC
Active plugins: [{"name":"InvenTreeBarcode","slug":"inventreebarcode","version":"2.2.0"},{"name":"BOM Exporter","slug":"bom-exporter","version":"1.1.0"},{"name":"InvenTree Exporter","slug":"inventree-exporter","version":"1.0.0"},{"name":"Parameter Exporter","slug":"parameter-exporter","version":"2.0.0"},{"name":"InvenTreeEmailNotifications","slug":"inventree-email-notification","version":"1.0.0"},{"name":"InvenTreeUINotifications","slug":"inventree-ui-notification","version":"1.0.0"},{"name":"InvenTreeCurrencyExchange","slug":"inventreecurrencyexchange","version":"1.0.0"},{"name":"InvenTreeMachines","slug":"inventree-machines","version":"1.0.0"},{"name":"InvenTreeLabel","slug":"inventreelabel","version":"1.1.0"},{"name":"InvenTreeLabelMachine","slug":"inventreelabelmachine","version":"1.0.0"}]
- InvenTree 1.5.4, official
inventree/inventreeimage. - Image digest:
sha256:a946ec09da3e5a5b7343fb7d02f2367f74167f4ce883a62e4a313db7bdb9bd54. - Python 3.14.
- Kubernetes, separate web-server and background-worker containers.
- Persistent PostgreSQL database and
/home/inventree/datavolume. - Python package installations are container-local; no persistent virtual environment.
PLUGIN_ON_STARTUP=Trueand plugin support enabled.
The persistent requirements file contains:
inventree-brother-plugin
inventree-zebra-plugin
inventree-mcp
Try to reproduce on the demo site
I did not try to reproduce
Is the bug reproducible on the demo site?
Not reproducible
Relevant log output
I have reviewed this report for correctness and filled out all sections.
- I have checked this report. I acknowledge that filing bugs via AI agents without review might lead to being blocked.
Activity
kquinsland01 commentedon Sep 13, 2026
I have a work-around but it's inelegant.
This script is mounted into the pod @
/etc/inventree/start-with-plugins.py:And then in both the
serverandworkerdeployment, I am doing this:SchrodingersGat commentedon Sep 15, 2026
@kquinsland thanks for reporting - please review #12858
kquinsland01 commentedon Sep 15, 2026
Oh that's a simpler way to do it. When I wrote this issue up the other day I could only think of less clean way to do this.