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

Fix install command for Postgres 16 on macOS #1300

Merged
merged 2 commits into from
Sep 19, 2023
Merged

Fix install command for Postgres 16 on macOS #1300

merged 2 commits into from
Sep 19, 2023

Conversation

bayandin
Copy link
Contributor

Since Postgres 16, the shared library extension on macOS is .dylib instead of .so.
Ref postgres/postgres@b55f62a

@bayandin bayandin changed the title Fix install for Postgres 16 on macOS Fix install command for Postgres 16 on macOS Sep 17, 2023
@workingjubilee
Copy link
Member

Does this actually fix any incorrect behaviors in a practical use-case, or is this mere adherence to convention? The change in the Postgres build system does not change what dynamic libraries Postgres will load correctly.

@bayandin
Copy link
Contributor Author

bayandin commented Sep 18, 2023

Does this actually fix any incorrect behaviors in a practical use-case, or is this mere adherence to convention? The change in the Postgres build system does not change what dynamic libraries Postgres will load correctly.

Yep, it does fix an incorrect behaviour (I should've added it to the PR description straight away):

$ cargo install --locked cargo-pgrx # 0.10.1
$ cargo pgrx init
$ cargo pgrx new example
$ cd example
$ RUST_BACKTRACE=all PG_VERSION=pg16 cargo pgrx test
       Using CliArgument("pg16") and `pg_config` from /Users/bayandin/.pgrx/16.0/pgrx-install/bin/pg_config
CARGO_TARGET_DIR="/Users/bayandin/example/target" PGRX_ALL_FEATURES="false" PGRX_BUILD_PROFILE="dev" PGRX_FEATURES="pg16 pg_test" PGRX_NO_DEFAULT_FEATURES="true" PGRX_NO_SCHEMA="false" "/opt/homebrew/Cellar/rust/1.72.0_1/bin/cargo" "test" "--features" "pg16 pg_test" "--no-default-features"
    Finished test [unoptimized + debuginfo] target(s) in 0.08s
     Running unittests src/lib.rs (target/debug/deps/example-1e29ce3ea90b2f3c)

running 1 test
    Building extension with features pg16 pg_test
     Running command "/opt/homebrew/Cellar/rust/1.72.0_1/bin/cargo" "build" "--features" "pg16 pg_test" "--no-default-features" "--message-format=json-render-diagnostics"
  Installing extension
     Copying control file to /Users/bayandin/.pgrx/16.0/pgrx-install/share/postgresql/extension/example.control
     Copying shared library to /Users/bayandin/.pgrx/16.0/pgrx-install/lib/postgresql/example.so
    Finished installing example
test tests::pg_test_hello_example ... FAILED

failures:

---- tests::pg_test_hello_example stdout ----
installing extension
detected cargo args: Features { all_features: false, no_default_features: true, features: ["pg16", "pg_test"] }
"/Users/bayandin/.pgrx/16.0/pgrx-install/bin/postgres" "-D" "/Users/bayandin/example/target/pgrx-test-data-16" "-h" "localhost" "-p" "32216" "-c" "log_destination=stderr" "-c" "logging_collector=off"
pid=15723
PostgreSQL 16.0 on aarch64-apple-darwin22.6.0, compiled by Apple clang version 14.0.3 (clang-1403.0.22.14.1), 64-bit
[2023-09-18 08:43:43.124 BST] [15723] [6507ffaf.3d6b]: LOG:  starting PostgreSQL 16.0 on aarch64-apple-darwin22.6.0, compiled by Apple clang version 14.0.3 (clang-1403.0.22.14.1), 64-bit
[2023-09-18 08:43:43.126 BST] [15723] [6507ffaf.3d6b]: LOG:  listening on IPv6 address "::1", port 32216
[2023-09-18 08:43:43.126 BST] [15723] [6507ffaf.3d6b]: LOG:  listening on IPv4 address "127.0.0.1", port 32216
[2023-09-18 08:43:43.127 BST] [15723] [6507ffaf.3d6b]: LOG:  listening on Unix socket "/Users/bayandin/.pgrx/.s.PGSQL.32216"
[2023-09-18 08:43:43.129 BST] [15726] [6507ffaf.3d6e]: LOG:  database system was shut down at 2023-09-18 08:39:10 BST
     Creating database pgrx_tests
thread 'tests::pg_test_hello_example' panicked at 'There was an issue creating the extension 'example' in Postgres: 

Caused by:
    ERROR SQLSTATE[58P01]: could not access file "$libdir/example": No such file or directory
    query: CREATE EXTENSION example CASCADE;
    params: None

Location:
    /Users/bayandin/.cargo/registry/src/index.crates.io-6f17d22bba15001f/pgrx-tests-0.10.1/src/framework.rs:104:21', src/lib.rs:15:5
stack backtrace:
   0: _rust_begin_unwind
   1: core::panicking::panic_fmt
   2: example::tests::pg_test_hello_example
             at ./src/lib.rs:15:5
   3: example::tests::pg_test_hello_example::{{closure}}
             at ./src/lib.rs:15:5
   4: core::ops::function::FnOnce::call_once
             at /private/tmp/rust-20230901-16881-ycyewx/rustc-1.72.0-src/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.


failures:
    tests::pg_test_hello_example

test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 1.00s

stopping postgres (pid=15723)
error: test failed, to rerun pass `--lib`

And it work if I install pgrx with this patch:

$ cargo install --git=https://github.com/bayandin/pgrx --rev=2d39b90382f6eabf8f4d731bb7d287a320472a4c cargo-pgrx # this fix
$ RUST_BACKTRACE=all PG_VERSION=pg16 cargo pgrx test
RUST_BACKTRACE=all PG_VERSION=pg16 cargo pgrx test                                                            
       Using CliArgument("pg16") and `pg_config` from /Users/bayandin/.pgrx/16.0/pgrx-install/bin/pg_config
CARGO_TARGET_DIR="/Users/bayandin/example/target" PGRX_ALL_FEATURES="false" PGRX_BUILD_PROFILE="dev" PGRX_FEATURES="pg16 pg_test" PGRX_NO_DEFAULT_FEATURES="true" PGRX_NO_SCHEMA="false" "/opt/homebrew/Cellar/rust/1.72.0_1/bin/cargo" "test" "--features" "pg16 pg_test" "--no-default-features"
    Finished test [unoptimized + debuginfo] target(s) in 0.14s
     Running unittests src/lib.rs (target/debug/deps/example-1e29ce3ea90b2f3c)

running 1 test
    Building extension with features pg_test pg16
     Running command "/opt/homebrew/Cellar/rust/1.72.0_1/bin/cargo" "build" "--features" "pg_test pg16" "--no-default-features" "--message-format=json-render-diagnostics"
  Installing extension
     Copying control file to /Users/bayandin/.pgrx/16.0/pgrx-install/share/postgresql/extension/example.control
     Copying shared library to /Users/bayandin/.pgrx/16.0/pgrx-install/lib/postgresql/example.dylib
    Finished installing example
test tests::pg_test_hello_example ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 1.01s

stopping postgres (pid=16691)

@workingjubilee
Copy link
Member

workingjubilee commented Sep 18, 2023

RUST_BACKTRACE=all

You want RUST_BACKTRACE="full"

Okay, this should have been caught by a test. I believe this should track the latest:

cargo_pgrx_init:
name: cargo pgrx init
runs-on: PGRX
if: "!contains(github.event.head_commit.message, 'nogha')"
env:
RUSTC_WRAPPER: sccache
SCCACHE_DIR: /home/runner/.cache/sccache
strategy:
matrix:
version: ["postgres-15"]

@bayandin
Copy link
Contributor Author

RUST_BACKTRACE=all

You want RUST_BACKTRACE="full"

Oopsie, of course 😄

Okay, this should have been caught by a test. I believe this should track the latest:

cargo_pgrx_init:
name: cargo pgrx init
runs-on: PGRX
if: "!contains(github.event.head_commit.message, 'nogha')"
env:
RUSTC_WRAPPER: sccache
SCCACHE_DIR: /home/runner/.cache/sccache
strategy:
matrix:
version: ["postgres-15"]

That one is on Linux.
I believe this one could have caught it, but it uses Postgres 14

build_mac:
name: MacOS build & test
runs-on: ${{ matrix.os }}
if: "!contains(github.event.head_commit.message, 'nogha')"
env:
RUSTC_WRAPPER: sccache
SCCACHE_DIR: /Users/runner/Library/Caches/Mozilla.sccache
SCCACHE_IDLE_TIMEOUT: 0
strategy:
matrix:
os: ["macos-11"]

I'm happy to adjust the CI pipeline to use different Postgres versions on macOS. Let me know if you want me to add it.

@workingjubilee
Copy link
Member

Oh, whoops. Silly me.

Yes, please do, with a comment about why the particular version.

@workingjubilee workingjubilee merged commit 8bf7bbf into pgcentralfoundation:develop Sep 19, 2023
9 checks passed
@bayandin bayandin deleted the fix-macos-pg16 branch September 19, 2023 00:52
@workingjubilee
Copy link
Member

Thank you!

eeeebbbbrrrr pushed a commit that referenced this pull request Sep 19, 2023
Since Postgres 16, the shared library extension on macOS is `.dylib`
instead of `.so`. Ref:
postgres/postgres@b55f62a

This fixes some problems with `cargo pgrx` commands on macOS.
workingjubilee added a commit that referenced this pull request Sep 19, 2023
Welcome to pgrx v0.10.2!

In pgrx v0.10.0, as part of a refactoring step in order to make
refactoring easier in the future, without things like losing track of
random functions, we... omitted a few functions! These depended on the
cshim, but were not direct bindings, themselves. Oops. They're back now
in `pgrx::pg_sys`.

## `cargo pgrx` works now for Postgres 16 on macOS

Installing extensions on macOS for Postgres 16 had problems due to
recent changes to Postgres defaults. We have fixed this and expanded our
test coverage for macOS to reduce the odds of this happening in the
future, thanks to @bayandin in
#1300

## composites compose better

There were some problems with composite types and arrays, and
specifically arrays of composite types in composite types. These are the
sorts of things that cause edge cases in PgHeapTuple. They should now be
appropriately supported, however, thanks to @eeeebbbbrrrr in
#1303

## `#[pg_schema]` will enable your bad ideas

The following should now work appropriately:
```rust
#[pgrx::pg_schema]
mod pg_catalog {
```

It does what you think it does. Since this can affect a global namespace
in a way that makes it much easier to conflict with other extensions, it
is best to avoid this. However, it is the sort of bad idea that
extensions which "take over" the Postgres host extensively redefine the
host's capabilities, like https://www.zombodb.com/ does, may
have to resort to in order to accomplish their goal. Thanks to
@eeeebbbbrrrr in #1302

## Keep the bug reports coming

And thank _you_ for reporting your issues!
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.

2 participants