pgrx icon indicating copy to clipboard operation
pgrx copied to clipboard

Bindgen issue upgrading to 0.11.x in MacOS Postgres.app installation

Open joaohaas opened this issue 1 year ago • 3 comments

Hey, at work we're trying to upgrade our pgrx version from 0.10.2 to 0.11.4, but we're running into issues when compiling pgrx-pg-sys. We're able to compile 0.10.x just fine, and the issue appears in all 0.11.x versions.

Based off the logs, I think it's failing to get all of my include paths, so maybe it's an issue with another package or my local env? I found this old post with a similar issue, but I do not have LLVM installed through brew.

For reference, I'm running the Postgres.app installation, which I know has caused issues in the past due to changes from the 'official' release, but I'm not sure if that's the case this time. I'm also running MacOS 13.3, but my coworker is running Sonoma and is also facing this issue.

Here's the log, lmk if you need any additional information/testing:

   Compiling pgrx-pg-sys v0.11.4
error: failed to run custom build command for `pgrx-pg-sys v0.11.4`

Caused by:
  process didn't exit successfully: `/Users/<user>/<project>/target/debug/build/pgrx-pg-sys-ef78b9fc3b27284f/build-script-build` (exit status: 1)
  --- stdout
  cargo:rerun-if-env-changed=PGRX_BUILD_VERBOSE
  cargo:rerun-if-env-changed=PGRX_PG_SYS_GENERATE_BINDINGS_FOR_RELEASE
  cargo:rustc-cfg=nightly
  cargo:rerun-if-env-changed=PGRX_PG_CONFIG_PATH
  cargo:rerun-if-env-changed=PGRX_PG_CONFIG_AS_ENV
  cargo:rerun-if-env-changed=LLVM_CONFIG_PATH
  cargo:rerun-if-env-changed=LIBCLANG_PATH
  cargo:rerun-if-env-changed=LIBCLANG_STATIC_PATH
  cargo:rerun-if-env-changed=BINDGEN_EXTRA_CLANG_ARGS
  cargo:rerun-if-env-changed=BINDGEN_EXTRA_CLANG_ARGS_aarch64-apple-darwin
  cargo:rerun-if-env-changed=BINDGEN_EXTRA_CLANG_ARGS_aarch64_apple_darwin
  cargo:rerun-if-env-changed=PGRX_PG_SYS_GENERATE_BINDINGS_FOR_RELEASE
  cargo:rerun-if-changed=include
  cargo:rerun-if-changed=cshim
  cargo:rerun-if-changed=/Users/<user>/.pgrx/config.toml
  cargo:rerun-if-env-changed=PGRX_TARGET_INFO_PATH_PG15_aarch64-apple-darwin
  cargo:rerun-if-env-changed=PGRX_TARGET_INFO_PATH_PG15
  cargo:rerun-if-env-changed=PGRX_BINDGEN_NO_DETECT_INCLUDES_aarch64-apple-darwin
  cargo:rerun-if-env-changed=PGRX_BINDGEN_NO_DETECT_INCLUDES
  cargo:rerun-if-env-changed=PGRX_INCLUDEDIR_SERVER_PG15_aarch64-apple-darwin
  cargo:rerun-if-env-changed=PGRX_INCLUDEDIR_SERVER_PG15
  cargo:rerun-if-env-changed=PGRX_INCLUDEDIR_SERVER_aarch64-apple-darwin
  cargo:rerun-if-env-changed=PGRX_INCLUDEDIR_SERVER

  --- stderr
  build_paths=BuildPaths { manifest_dir: "/Users/<user>/.cargo/registry/src/index.crates.io-6f17d22bba15001f/pgrx-pg-sys-0.11.4", out_dir: "/Users/<user>/<project>/target/debug/build/pgrx-pg-sys-56adcb0b1e596b17/out", src_dir: "/Users/<user>/.cargo/registry/src/index.crates.io-6f17d22bba15001f/pgrx-pg-sys-0.11.4/src/include", shim_src: "/Users/<user>/.cargo/registry/src/index.crates.io-6f17d22bba15001f/pgrx-pg-sys-0.11.4/cshim", shim_dst: "/Users/<user>/<project>/target/debug/build/pgrx-pg-sys-56adcb0b1e596b17/out/cshim" }
  Generating bindings for pg15
  pg_config --configure CLANG = None
  Bindgen found Apple clang version 14.0.3 (clang-1403.0.22.14.1)
  found libclang at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/libclang.dylib
  Found include dirs ["/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/14.0.3/include"]
  /Applications/Postgres.app/Contents/Versions/15/include/postgresql/server/c.h:59:10: fatal error: 'stdio.h' file not found
  Error: bindgen failed for pg15

  Caused by:
     0: Unable to generate bindings for pg15
     1: clang diagnosed error: /Applications/Postgres.app/Contents/Versions/15/include/postgresql/server/c.h:59:10: fatal error: 'stdio.h' file not found


  Location:
      /Users/<user>/.cargo/registry/src/index.crates.io-6f17d22bba15001f/pgrx-pg-sys-0.11.4/build.rs:736:10

joaohaas avatar May 07 '24 13:05 joaohaas

This is likely breaking on https://github.com/pgcentralfoundation/pgrx/pull/1325

workingjubilee avatar May 07 '24 19:05 workingjubilee

Is there a known workaround?

joleeee avatar Mar 09 '25 16:03 joleeee

Somehow it worked to have pgrx download pg itself but install towards Postgres.app installation

cargo pgrx init --pg16=download
cargo pgrx install --release -c /Applications/Postgres.app/Contents/Versions/latest/bin/pg_config

joleeee avatar Mar 09 '25 16:03 joleeee