Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Darwin bundle fully self-contained by including libpq #135

Closed

Conversation

glasser
Copy link

@glasser glasser commented Jan 9, 2020

libpq is the C Postgres client library. It is used by bin/initdb which is
packaged and run by this project.

While the Linux and Windows tarballs contain libpq, the Mac (Darwin) one does
not. This mostly works out ok because Macs ship with /usr/lib/libpq.5.dylib (and
you can install your own libpq to other places like /usr/local/lib with, eg,
Homebrew), but this might be a surprising version or may be misinstalled. (I
discovered this problem when my Homebrew Postgres installation was misinstalled
and it broke EmbeddedPostgres.)

By packaging libpq with the Darwin bundle, EmbeddedPostgres can be fully
self-contained on Mac.

You can verify this as follows:

./repack-postgres.sh
mkdir unpacked
cd unpacked
tar xJf ../target/generated-resources/postgresql-Darwin-x86_64.txz
DYLD_PRINT_LIBRARIES=YES ./bin/initdb --version 2>&1 | grep libpq

Before this change, the final command reads:

dyld: loaded: /usr/lib/libpq.5.dylib

After this change, it reads:

dyld: loaded: /private/tmp/otj-pg-embedded/unpacked/./bin/../lib/libpq.5.dylib

libpq is the C Postgres client library. It is used by bin/initdb which is
packaged and run by this project.

While the Linux and Windows tarballs contain libpq, the Mac (Darwin) one does
not. This mostly works out ok because Macs ship with /usr/lib/libpq.5.dylib (and
you can install your own libpq to other places like /usr/local/lib with, eg,
Homebrew), but this might be a surprising version or may be misinstalled. (I
discovered this problem when my Homebrew Postgres installation was misinstalled
and it broke EmbeddedPostgres.)

By packaging libpq with the Darwin bundle, EmbeddedPostgres can be fully
selfcontained on Mac.

You can verify this as follows:

    ./repack-postgres.sh
    mkdir unpacked
    cd unpacked
    tar xJf ../target/generated-resources/postgresql-Darwin-x86_64.txz
    DYLD_PRINT_LIBRARIES=YES ./bin/initdb --version 2>&1 | grep libpq

Before this change, the final command reads:

    dyld: loaded: /usr/lib/libpq.5.dylib

After this change, it reads:

    dyld: loaded: /private/tmp/otj-pg-embedded/unpacked/./bin/../lib/libpq.5.dylib
@ciAnd7
Copy link

ciAnd7 commented Nov 16, 2020

It looks like MacOS 11 (Big Sur) doesn't ship libpq.5.dylib. So it is not possible to use pg-embedded without libpq.5.dylib

@glasser
Copy link
Author

glasser commented Nov 17, 2020

As in, this PR is required for use on Big Sur?

This project seems like it may be dead. I'll note that this fork did merge my PR.

@ciAnd7
Copy link

ciAnd7 commented Nov 17, 2020

Yes. This PR is required for Big Sur. I've tested it in my environment and it works just fine.

Thank you for link to zonkyio fork. I will check it.

Copy link

@larinme larinme left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It helped for me

@mikebell90
Copy link
Contributor

We are going the docker route, making this PR obsolete

@mikebell90 mikebell90 closed this Jan 10, 2022
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.

None yet

4 participants