Skip to content

fix: ship libmariadb3 in runtime image and clarify missing-system-library error (#988)#997

Draft
Bl3f wants to merge 2 commits into
mainfrom
cursor/fix-mysql-libmariadb-988-69d3
Draft

fix: ship libmariadb3 in runtime image and clarify missing-system-library error (#988)#997
Bl3f wants to merge 2 commits into
mainfrom
cursor/fix-mysql-libmariadb-988-69d3

Conversation

@Bl3f

@Bl3f Bl3f commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #988 — the getnao/nao Docker image bundled mysqlclient (built against MariaDB Connector/C) but not its runtime shared library libmariadb.so.3, so any MySQL datasource failed at import time with a misleading "package required" message.

Two changes:

  1. Dockerfile — install libmariadb3 in the runtime stage so import MySQLdb (and thus the ibis MySQL backend) works out of the box. The builder stage already installs libmariadb-dev; only the runtime lib was missing.
  2. cli/nao_core/deps.pyrequire_database_backend / require_dependency previously caught any ImportError and reported pip 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 → existing MissingDependencyError (pip/uv install hint).
    • Plain ImportError from a failed shared-object load → new MissingSystemLibraryError that surfaces the real loader error (e.g. libmariadb.so.3: cannot open shared object file) and suggests installing the system library.
    • Any other ImportError is re-raised unchanged instead of being masked.

Root cause

$ python -c "import ibis.backends.mysql"
ImportError: libmariadb.so.3: cannot open shared object file: No such file or directory

ibis/backends/mysql/__init__.py imports MySQLdb at module load; MySQLdb._mysql links libmariadb.so.3. With the lib absent, the import raises ImportError, which require_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 passed
  • make lint (ty, ruff check, ruff format) — all checks passed
  • ✅ End-to-end repro: hid /lib/x86_64-linux-gnu/libmariadb.so.3 and confirmed the new message; restoring the lib makes require_database_backend("mysql") succeed.
  • ✅ Confirmed libmariadb3 provides /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.

Open in Web Open in Cursor 

Review in cubic

cursoragent and others added 2 commits June 29, 2026 19:49
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>
@github-actions

Copy link
Copy Markdown
Contributor

🚀 Preview Deployment

URL https://pr-997-0e976d0.preview.getnao.io
Commit 0e976d0

⚠️ No LLM API keys configured - you'll see the API key setup flow when trying to chat.


Preview will be automatically removed when this PR is closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mysqlclient shipped without its runtime lib libmariadb.so.3 → MySQL backend unusable in 0.2.3 image

2 participants