mcp-context-forge icon indicating copy to clipboard operation
mcp-context-forge copied to clipboard

[BUG]: ImportError no pq wrapper available in Containerfile.lite

Open akshaymohan29 opened this issue 8 months ago • 0 comments

🐞 Bug Summary

psycopg fails to import in the Containerfile.lite runtime image on s390x architecture because libpq.so.5 is not found, despite libpq package being installed in the runtime stage.

Error message:

File "/app/.venv/lib64/python3.12/site-packages/psycopg/pq/__init__.py", line 108, in import_from_libpq
    raise ImportError(f"""\
ImportError: no pq wrapper available.
Attempts made:
- couldn't import psycopg 'c' implementation: libpq.so.5: cannot open shared object file: No such file or directory
- couldn't import psycopg 'binary' implementation: No module named 'psycopg_binary'
- couldn't import psycopg 'python' implementation: libpq library not found

🧩 Affected Component

Select the area of the project impacted:

  • [ ] mcpgateway - API
  • [ ] mcpgateway - UI (admin panel)
  • [ ] mcpgateway.wrapper - stdio wrapper
  • [ ] Federation or Transports
  • [ ] CLI, Makefiles, or shell scripts
  • [x] Container setup (Docker/Podman/Compose)
  • [ ] Other (explain below)

🔁 Steps to Reproduce

  1. Build Containerfile.lite on an s390x host (or using QEMU emulation):
    docker build -f Containerfile.lite -t mcpgateway-lite .
    
  2. Run the container:
    docker run mcpgateway-lite
    
  3. Observe the crash during startup when initializing the database extension.

🤔 Expected Behavior

The application should start successfully, and psycopg should be able to load the libpq library.


📓 Logs / Error Output

File "/app/.venv/lib64/python3.12/site-packages/psycopg/pq/__init__.py", line 108, in import_from_libpq
    raise ImportError(f"""\
ImportError: no pq wrapper available.
Attempts made:
- couldn't import psycopg 'c' implementation: libpq.so.5: cannot open shared object file: No such file or directory
- couldn't import psycopg 'binary' implementation: No module named 'psycopg_binary'
- couldn't import psycopg 'python' implementation: libpq library not found

🧠 Environment Info

Key Value
Version or commit main
Runtime Python 3.12
Platform / OS s390x / RHEL/UBI 10
Container Docker / Podman

🧩 Additional Context (optional)

On s390x, psycopg-binary wheels are often unavailable, so we build psycopg[c] from source. This requires libpq to be present at runtime. While libpq is installed via microdnf, it seems it's either not providing libpq.so.5 or it's not in the environment's library search path. Adding postgresql-libs or ensuring libpq is correctly linked may resolve this.

akshaymohan29 avatar Mar 23 '26 15:03 akshaymohan29