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

Installation problems with Postgres.app Universal Binary #1965

Open
jcgsville opened this issue Jan 7, 2025 · 0 comments
Open

Installation problems with Postgres.app Universal Binary #1965

jcgsville opened this issue Jan 7, 2025 · 0 comments

Comments

@jcgsville
Copy link

I'm trying to install pgrx locally so I can use supabase/pg_jsonschema.

I'm using Postgres.app v17 Universal binary on my M3 Mac.

pg_jsonschema seems to only work with pgrx 0.12.6, so I install it with the following command

cargo install cargo-pgrx --version 0.12.6 --locked

I don't want pgrx to install and manage any versions of postgres, because I'm not building any extensions myself, so I init with this command, which seems to work

cargo pgrx init --pg17 /Applications/Postgres.app/Contents/Versions/17/bin/pg_config
cargo pgrx init --pg17 /Applications/Postgres.app/Contents/Versions/17/bin/pg_config
warning: `/Users/chandler/Documents/pg_jsonschema/.cargo/config` is deprecated in favor of `config.toml`
note: if you need to support cargo 1.38 or earlier, you can symlink `config` to `config.toml`
   Validating /Applications/Postgres.app/Contents/Versions/17/bin/pg_config

Yet, when I pgrx install, I get an error:

sudo cargo pgrx init --pg17 /Applications/Postgres.app/Contents/Versions/17/bin/pg_config
error: failed to run custom build command for `pgrx-pg-sys v0.12.6`

Caused by:
  process didn't exit successfully: `/Users/chandler/Documents/pg_jsonschema/target/debug/build/pgrx-pg-sys-fe5c6f3adcec75c3/build-script-bindgen` (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: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=pgrx-cshim.c
  cargo:rerun-if-changed=/Users/chandler/.pgrx/config.toml
  cargo:rerun-if-env-changed=PGRX_TARGET_INFO_PATH_PG17_aarch64-apple-darwin
  cargo:rerun-if-env-changed=PGRX_TARGET_INFO_PATH_PG17
  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_PG17_aarch64-apple-darwin
  cargo:rerun-if-env-changed=PGRX_INCLUDEDIR_SERVER_PG17
  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/chandler/.cargo/registry/src/index.crates.io-6f17d22bba15001f/pgrx-pg-sys-0.12.6", out_dir: "/Users/chandler/Documents/pg_jsonschema/target/debug/build/pgrx-pg-sys-0d3eacb1737c5f73/out", src_dir: "/Users/chandler/.cargo/registry/src/index.crates.io-6f17d22bba15001f/pgrx-pg-sys-0.12.6/src/include", shim_src: "/Users/chandler/.cargo/registry/src/index.crates.io-6f17d22bba15001f/pgrx-pg-sys-0.12.6/pgrx-cshim.c", shim_dst: "/Users/chandler/Documents/pg_jsonschema/target/debug/build/pgrx-pg-sys-0d3eacb1737c5f73/out/pgrx-cshim.c" }
  Generating bindings for pg17
  pg_config --configure CLANG = None
  Bindgen found Apple clang version 16.0.0 (clang-1600.0.26.4)
  found libclang at /Library/Developer/CommandLineTools/usr/lib/libclang.dylib
  Found include dirs ["/Library/Developer/CommandLineTools/usr/lib/clang/16/include"]
  /Applications/Postgres.app/Contents/Versions/17/include/postgresql/server/c.h:59:10: fatal error: 'stdio.h' file not found
  Error: bindgen failed for pg17

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


  Location:
      /Users/chandler/.cargo/registry/src/index.crates.io-6f17d22bba15001f/pgrx-bindgen-0.12.6/src/build.rs:799:10

I've tried everything I can think of to figure out why Bindgen can't find stdio.h

I verified stdio.h is there:

ls /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/stdio.h

output

/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/stdio.h

I can compile a simple program that pulls that c.h file. Following outputs succesfully:

echo '#include "/Applications/Postgres.app/Contents/Versions/17/include/postgresql/server/c.h"\nint main() { return 0; }' | clang -xc - -o /dev/null

I've tried setting BINDGEN_EXTRA_CLANG_ARGS:

export BINDGEN_EXTRA_CLANG_ARGS="--sysroot=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk \
-I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include
-I/Applications/Postgres.app/Contents/Versions/17/include \
-I/Applications/Postgres.app/Contents/Versions/17/include/postgresql/server \
-I/Library/Developer/CommandLineTools/usr/include"

pgrx install still fails. Anyone have any suggestions? Might pgrx-bindgen-0.12.6/src/build.rs be doing something weird and not looking in the right place for the headers? stdio.h is the first non-pg-related header it's including:

less /Applications/Postgres.app/Contents/Versions/17/include/postgresql/server/c.h
#ifndef C_H
#define C_H

#include "postgres_ext.h"

/* Must undef pg_config_ext.h symbols before including pg_config.h */
#undef PG_INT64_TYPE

#include "pg_config.h"
#include "pg_config_manual.h"   /* must be after pg_config.h */
#include "pg_config_os.h"               /* must be before any system header files */

/* System header files that should be available everywhere in Postgres */
#include <stdio.h>
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

No branches or pull requests

1 participant