fix: ship libmariadb3 in runtime image and clarify missing-system-library error (#988)#997
Draft
Bl3f wants to merge 2 commits into
Draft
fix: ship libmariadb3 in runtime image and clarify missing-system-library error (#988)#997Bl3f wants to merge 2 commits into
Bl3f wants to merge 2 commits into
Conversation
The runtime image bundles mysqlclient (built against MariaDB Connector/C) but not its shared library libmariadb.so.3, so importing the MySQL backend fails with 'libmariadb.so.3: cannot open shared object file'. Install the libmariadb3 runtime package so the MySQL datasource works out of the box. Fixes #988 Co-authored-by: Christophe Blefari <christophe.blefari@gmail.com>
When an optional backend's Python package is installed but a native shared library it links against is missing (e.g. libmariadb.so.3 for MySQL), the import raises a plain ImportError. Previously this was masked as a misleading "package required, pip install nao-core[...]" message. Now such failures raise MissingSystemLibraryError, which surfaces the real loader error and suggests installing the system library. Co-authored-by: Christophe Blefari <christophe.blefari@gmail.com>
Contributor
🚀 Preview Deployment
Preview will be automatically removed when this PR is closed. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #988 — the
getnao/naoDocker image bundledmysqlclient(built against MariaDB Connector/C) but not its runtime shared librarylibmariadb.so.3, so any MySQL datasource failed at import time with a misleading "package required" message.Two changes:
Dockerfile— installlibmariadb3in the runtime stage soimport MySQLdb(and thus the ibis MySQL backend) works out of the box. The builder stage already installslibmariadb-dev; only the runtime lib was missing.cli/nao_core/deps.py—require_database_backend/require_dependencypreviously caught anyImportErrorand reportedpip install 'nao-core[mysql]', even when the real cause was a missing native library. They now distinguish the two cases:ModuleNotFoundError→ the Python package is genuinely missing → existingMissingDependencyError(pip/uv install hint).ImportErrorfrom a failed shared-object load → newMissingSystemLibraryErrorthat surfaces the real loader error (e.g.libmariadb.so.3: cannot open shared object file) and suggests installing the system library.ImportErroris re-raised unchanged instead of being masked.Root cause
ibis/backends/mysql/__init__.pyimportsMySQLdbat module load;MySQLdb._mysqllinkslibmariadb.so.3. With the lib absent, the import raisesImportError, whichrequire_database_backend("mysql")masked behind the "package required" message.Testing
uv run pytest tests/nao_core/test_deps.py— 5 passed (incl. new system-library / unrelated-error cases)uv run pytest tests/nao_core/commands/sync/test_database_provider.py— 12 passedmake lint(ty, ruff check, ruff format) — all checks passed/lib/x86_64-linux-gnu/libmariadb.so.3and confirmed the new message; restoring the lib makesrequire_database_backend("mysql")succeed.libmariadb3provides/usr/lib/x86_64-linux-gnu/libmariadb.so.3.Before vs. after error message:
mysql_error_message_before_after.txt
To show artifacts inline, enable in settings.