🐞 Compliation error on macOS 26 `cargo pgrx init`
I did try to run cargo pgrx init
rm -rf ~/.pgrx && \
export PKG_CONFIG_PATH="/opt/homebrew/opt/icu4c/lib/pkgconfig" && \
cargo pgrx init --pg17 download
But compilation failed:
Discovered Postgres v13.22, v14.19, v15.14, v16.10, v17.6, v18beta2
Creating PGRX_HOME at `/Users/dev/.pgrx`
Downloading Postgres v17.6 from https://ftp.postgresql.org/pub/source/v17.6/postgresql-17.6.tar.bz2
Untarring Postgres v17.6 to /Users/dev/.pgrx/17.6_unpack
Renaming /Users/dev/.pgrx/17.6_unpack/postgresql-17.6 -> /Users/dev/.pgrx/17.6
Configuring Postgres v17.6
Compiling Postgres v17.6
Error:
Full log:
However when I did run command below, compilation went well:
rm -rf ~/.pgrx && \
export PKG_CONFIG_PATH="/opt/homebrew/opt/icu4c/lib/pkgconfig" && \
export PATH=/usr/bin:$PATH && \
cargo pgrx init --pg17 download
Compilation failed due to a linker error during Postgres v17.6 compilation.
Homebrew’s ar was creating invalid Mach-O archives for libpgcommon.a and libpgport.a, causing the linker error (archive member '/' not a mach-o file). Using Apple’s ar ensured valid Mach-O archives, allowing the linker (ld) to successfully build the zic binary in src/timezone.
Just for case I did run
brew update
brew upgrade
brew cleanup
and tested again.
But this did not change outcome.
The final working command:
rm -rf ~/.pgrx && \
export PKG_CONFIG_PATH="/opt/homebrew/opt/icu4c/lib/pkgconfig" && \
export AR=/usr/bin/ar && \
cargo pgrx init --pg17 download
I hope this information brightens someone's day.
Things work fine on my Mac without this fix. You might check to see if there is something odd in your RUSTFLAGS. When I tried to add export RUSTFLAGS="-C force-frame-pointers=yes" to help with debugging an issue, the linker blew up with versioning errors.