Files
neuronetz-gateway/src/neuronetz_gateway/cli/manage.py
Stephan Berbig 64f1ebc484
Some checks failed
CI / ruff (push) Has been cancelled
CI / mypy --strict (push) Has been cancelled
CI / pytest (push) Has been cancelled
CI / bandit (push) Has been cancelled
CI / pip-audit (push) Has been cancelled
cli: graceful fallback when --write-env can't write the host-mounted .env
The CLI runs inside the gateway container as the non-root `gateway` user
(uid 10001). The .env file is typically host-mounted at /app/.env, owned
by the host user — so the container process can't write the
.env.tmp file `update_env_file()` creates for the atomic rename. That
surfaced as a raw PermissionError traceback from
`docker exec neuronetz-gateway neuronetz-gateway remove-backend …`.

Now both add-backend and remove-backend catch PermissionError / OSError
on the write, print a tidy red message, and tell the user the two ways
forward: re-run with `docker exec -u root …` (in-container root keeps
the same FS, just bypasses ownership), or paste the printed
OLLAMA_BACKENDS line manually. Exit 1 either way so scripts notice.
2026-05-27 23:07:48 +02:00

26 KiB