Skip to content

macOS arm64 pg_client 0.19.0 expects libpq from the standalone Homebrew formula #48

Description

@prrao87

Summary

Seems like a packaging compatibility issue, and could use a UX enhancement to not trip up new users working with homebrew on macOS.

The official macOS arm64 build of libpg_client.lbug_extension 0.19.0
references this absolute libpq path:

/opt/homebrew/opt/libpq/lib/libpq.5.dylib

That file is provided by Homebrew's standalone libpq formula. It is not
present on a machine that has PostgreSQL 18 installed only through the
postgresql@18 brew formula.

The same library is available at a different path on that installation:

/opt/homebrew/lib/postgresql@18/libpq.5.dylib

Because the extension records the first path in its install name, Ladybug
cannot load it on this setup. Relinking a copy of the extension to the second
path fixes the problem.

Environment

  • PostgreSQL 18.4 installed with Homebrew postgresql@18
  • macOS arm64
  • pg_client extension binary 0.19.0 from the official release
  • liblbug 0.19.1
  • Standalone Homebrew libpq formula not installed

Reproduction

Install PostgreSQL with brew install postgresql@18, without installing the
separate libpq formula. Then inspect the extension and the two possible
library paths:

otool -L libpg_client.lbug_extension | grep libpq
# 	/opt/homebrew/opt/libpq/lib/libpq.5.dylib (compatibility version 5.0.0, ...)

ls /opt/homebrew/opt/libpq/lib/libpq.5.dylib
# ls: no such file or directory

ls /opt/homebrew/lib/postgresql@18/libpq.5.dylib
# /opt/homebrew/lib/postgresql@18/libpq.5.dylib

Loading the extension then fails:

LOAD EXTENSION '/path/to/libpg_client.lbug_extension';

Workaround

Relink a disposable copy of the extension to the libpq installed by
postgresql@18:

install_name_tool -change \
  /opt/homebrew/opt/libpq/lib/libpq.5.dylib \
  /opt/homebrew/lib/postgresql@18/libpq.5.dylib \
  libpg_client.lbug_extension

The patched copy loads successfully.

Possible fixes

  • Use @rpath or a loader-relative install name and include the common
    Homebrew locations in LC_RPATH.
  • Bundle or statically link libpq if its licensing and distribution terms
    allow that.
  • Publish separate binaries for the supported Homebrew layouts, or relink the
    extension during installation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions