1

I am new to this, I should install everything with bundle install and I am stuck at the pg_query 1.3.0 gem. It seems to show me error

linking shared-object pg_query/pg_query.bundle 
ld: library not found for -lpg_query 
clang: error: linker command failed with exit code 1 (use -v to see invocation) make: *** [pg_query.bundle] Error 1`

This is the whole log after bundle install:

Fetching pg_query 1.3.0
Installing pg_query 1.3.0 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /Users/dominikkrautstengel/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/pg_query-1.3.0/ext/pg_query
/Users/dominikkrautstengel/.rbenv/versions/2.7.2/bin/ruby -I /Users/dominikkrautstengel/.rbenv/versions/2.7.2/lib/ruby/2.7.0 -r
./siteconf20221123-20970-12vwdyo.rb extconf.rb
compiling src/pg_query.c
compiling src/pg_query_fingerprint.c
compiling src/pg_query_json.c
compiling src/pg_query_json_plpgsql.c
compiling src/pg_query_normalize.c
compiling src/pg_query_parse.c
compiling src/pg_query_parse_plpgsql.c
compiling src/postgres/contrib_pgcrypto_sha1.c
compiling src/postgres/src_backend_catalog_namespace.c
compiling src/postgres/src_backend_catalog_pg_proc.c
compiling src/postgres/src_backend_lib_stringinfo.c
compiling src/postgres/src_backend_libpq_pqcomm.c
compiling src/postgres/src_backend_nodes_bitmapset.c
compiling src/postgres/src_backend_nodes_copyfuncs.c
compiling src/postgres/src_backend_nodes_equalfuncs.c
compiling src/postgres/src_backend_nodes_extensible.c
compiling src/postgres/src_backend_nodes_list.c
compiling src/postgres/src_backend_nodes_makefuncs.c
compiling src/postgres/src_backend_nodes_nodeFuncs.c
compiling src/postgres/src_backend_nodes_value.c
compiling src/postgres/src_backend_parser_gram.c
In file included from gram.y:46:
In file included from ./src/postgres/include/postgres.h:47:
In file included from ./src/postgres/include/c.h:1224:
In file included from ./src/postgres/include/port.h:17:
In file included from
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/netdb.h:91:
In file included from
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/netinet/in.h:81:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/socket.h:425:1: error:
expected ';' after top level declarator
__CCT_DECLARE_CONSTRAINED_PTR_TYPES(struct sockaddr, sockaddr);
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/constrained_ctypes.h:587:101:
note: expanded from macro '__CCT_DECLARE_CONSTRAINED_PTR_TYPES'
#define __CCT_DECLARE_CONSTRAINED_PTR_TYPES(basetype, basetag)                                      \
                                                                                                    ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/constrained_ctypes.h:580:2:
note: expanded from macro '\
__CCT_DECLARE_CONSTRAINED_PTR_TYPE'
        __CCT_DISPATCH(__CCT_DECLARE_CONSTRAINED_PTR_TYPE, basetype, basetag, __VA_ARGS__)
        ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/constrained_ctypes.h:548:2:
note: expanded from macro '__CCT_DISPATCH'
        __CCT_DISPATCH1(base, __CCT_COUNT_ARGS(__VA_ARGS__), __VA_ARGS__)
        ^
note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/cdefs.h:113:26: note:
expanded from macro '__CONCAT'
#define __CONCAT(x, y)   x ## y
                         ^
<scratch space>:415:1: note: expanded from here
__CCT_DECLARE_CONSTRAINED_PTR_TYPE_3
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/constrained_ctypes.h:563:14:
note: expanded from macro '__CCT_DECLARE_CONSTRAINED_PTR_TYPE_3'
        __CCT_DEFER(__CONCAT, basetag,  __CCT_CONTRACT_LIST_TO_TAGGED_SUFFIX_1(kind))
                    ^
In file included from gram.y:46:
In file included from ./src/postgres/include/postgres.h:47:
In file included from ./src/postgres/include/c.h:1224:
In file included from ./src/postgres/include/port.h:17:
In file included from
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/netdb.h:91:
In file included from
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/netinet/in.h:81:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/socket.h:425:1: error:
expected ';' after top level declarator
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/constrained_ctypes.h:588:101:
note: expanded from macro '__CCT_DECLARE_CONSTRAINED_PTR_TYPES'
__CCT_DECLARE_CONSTRAINED_PTR_TYPE(basetype, basetag, REF);                                         \
                                                                                                    ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/constrained_ctypes.h:580:2:
note: expanded from macro '\
__CCT_DECLARE_CONSTRAINED_PTR_TYPE'
        __CCT_DISPATCH(__CCT_DECLARE_CONSTRAINED_PTR_TYPE, basetype, basetag, __VA_ARGS__)
        ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/constrained_ctypes.h:548:2:
note: expanded from macro '__CCT_DISPATCH'
        __CCT_DISPATCH1(base, __CCT_COUNT_ARGS(__VA_ARGS__), __VA_ARGS__)
        ^
note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/cdefs.h:113:26: note:
expanded from macro '__CONCAT'
#define __CONCAT(x, y)   x ## y
                         ^
<scratch space>:420:1: note: expanded from here
__CCT_DECLARE_CONSTRAINED_PTR_TYPE_4
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/constrained_ctypes.h:567:11:
note: expanded from macro '__CCT_DECLARE_CONSTRAINED_PTR_TYPE_4'
                 * __CCT_CONTRACT_TO_ATTR(kind2)                                                        \
                 ^
In file included from gram.y:46:
In file included from ./src/postgres/include/postgres.h:47:
In file included from ./src/postgres/include/c.h:1224:
In file included from ./src/postgres/include/port.h:17:
In file included from
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/netdb.h:91:
In file included from
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/netinet/in.h:81:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/socket.h:471:1: error:
typedef redefinition with different types ('struct sockaddr_storage *' vs 'struct sockaddr *')
__CCT_DECLARE_CONSTRAINED_PTR_TYPES(struct sockaddr_storage, sockaddr_storage);
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/constrained_ctypes.h:587:101:
note: expanded from macro '__CCT_DECLARE_CONSTRAINED_PTR_TYPES'
#define __CCT_DECLARE_CONSTRAINED_PTR_TYPES(basetype, basetag)                                      \
                                                                                                    ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/constrained_ctypes.h:580:2:
note: expanded from macro '\
__CCT_DECLARE_CONSTRAINED_PTR_TYPE'
        __CCT_DISPATCH(__CCT_DECLARE_CONSTRAINED_PTR_TYPE, basetype, basetag, __VA_ARGS__)
        ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/constrained_ctypes.h:548:2:
note: expanded from macro '__CCT_DISPATCH'
        __CCT_DISPATCH1(base, __CCT_COUNT_ARGS(__VA_ARGS__), __VA_ARGS__)
        ^
note: (skipping 4 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/constrained_ctypes.h:540:38:
note: expanded from macro '__CCT_CONTRACT_TO_ATTR'
#define __CCT_CONTRACT_TO_ATTR(kind) __CONCAT(__CCT_CONTRACT_ATTR_, kind)
                                     ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/cdefs.h:113:26: note:
expanded from macro '__CONCAT'
#define __CONCAT(x, y)   x ## y
             
pg_query_ruby.c:63:41: warning: '}' and ')' tokens terminating statement expression appear in different macro expansion contexts
[-Wcompound-token-split-by-macro]
        cPgQuery    = rb_const_get(rb_cObject, rb_intern("PgQuery"));
                                               ^~~~~~~~~~~~~~~~~~~~
/Users/dominikkrautstengel/.rbenv/versions/2.7.2/include/ruby-2.7.0/ruby/ruby.h:1847:24: note: expanded from macro 'rb_intern'
        __extension__ (RUBY_CONST_ID_CACHE((ID), (str))) : \
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/dominikkrautstengel/.rbenv/versions/2.7.2/include/ruby-2.7.0/ruby/ruby.h:1837:5: note: expanded from macro 'RUBY_CONST_ID_CACHE'
    }
    ^
pg_query_ruby.c:63:41: note: ')' token is here
        cPgQuery    = rb_const_get(rb_cObject, rb_intern("PgQuery"));
                                               ^~~~~~~~~~~~~~~~~~~~
/Users/dominikkrautstengel/.rbenv/versions/2.7.2/include/ruby-2.7.0/ruby/ruby.h:1847:56: note: expanded from macro 'rb_intern'
        __extension__ (RUBY_CONST_ID_CACHE((ID), (str))) : \
                                                       ^
pg_query_ruby.c:64:42: warning: '(' and '{' tokens introducing statement expression appear in different macro expansion contexts
[-Wcompound-token-split-by-macro]
        cParseError = rb_const_get_at(cPgQuery, rb_intern("ParseError"));
                                                ^~~~~~~~~~~~~~~~~~~~~~~
/Users/dominikkrautstengel/.rbenv/versions/2.7.2/include/ruby-2.7.0/ruby/ruby.h:1847:23: note: expanded from macro 'rb_intern'
        __extension__ (RUBY_CONST_ID_CACHE((ID), (str))) : \
                      ^
pg_query_ruby.c:64:42: note: '{' token is here
        cParseError = rb_const_get_at(cPgQuery, rb_intern("ParseError"));
                                                ^~~~~~~~~~~~~~~~~~~~~~~
/Users/dominikkrautstengel/.rbenv/versions/2.7.2/include/ruby-2.7.0/ruby/ruby.h:1847:24: note: expanded from macro 'rb_intern'
        __extension__ (RUBY_CONST_ID_CACHE((ID), (str))) : \
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/dominikkrautstengel/.rbenv/versions/2.7.2/include/ruby-2.7.0/ruby/ruby.h:1832:5: note: expanded from macro 'RUBY_CONST_ID_CACHE'
    {                                                   \
    ^
pg_query_ruby.c:64:42: warning: '}' and ')' tokens terminating statement expression appear in different macro expansion contexts
[-Wcompound-token-split-by-macro]
        cParseError = rb_const_get_at(cPgQuery, rb_intern("ParseError"));
                                                ^~~~~~~~~~~~~~~~~~~~~~~
/Users/dominikkrautstengel/.rbenv/versions/2.7.2/include/ruby-2.7.0/ruby/ruby.h:1847:24: note: expanded from macro 'rb_intern'
        __extension__ (RUBY_CONST_ID_CACHE((ID), (str))) : \
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/dominikkrautstengel/.rbenv/versions/2.7.2/include/ruby-2.7.0/ruby/ruby.h:1837:5: note: expanded from macro 'RUBY_CONST_ID_CACHE'
    }
    ^
pg_query_ruby.c:64:42: note: ')' token is here
        cParseError = rb_const_get_at(cPgQuery, rb_intern("ParseError"));
                                                ^~~~~~~~~~~~~~~~~~~~~~~
/Users/dominikkrautstengel/.rbenv/versions/2.7.2/include/ruby-2.7.0/ruby/ruby.h:1847:56: note: expanded from macro 'rb_intern'
        __extension__ (RUBY_CONST_ID_CACHE((ID), (str))) : \
                                                       ^
pg_query_ruby.c:59:1: warning: function 'raise_ruby_fingerprint_error' could be declared with attribute 'noreturn' [-Wmissing-noreturn]
{
^
17 warnings generated.
linking shared-object pg_query/pg_query.bundle
ld: library not found for -lpg_query
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [pg_query.bundle] Error 1

make failed, exit code 2

Gem files will remain installed in /Users/dominikkrautstengel/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/pg_query-1.3.0 for inspection.
Results logged to
/Users/dominikkrautstengel/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/extensions/arm64-darwin-22/2.7.0/pg_query-1.3.0/gem_make.out

An error occurred while installing pg_query (1.3.0), and Bundler cannot continue.
Make sure that `gem install pg_query -v '1.3.0'` succeeds before bundling.

In Gemfile:
  prosopite was resolved to 0.2.1, which depends on
    pg_query

I have latest Xcode installed and Command Line Tools also. But as I said, I do not understand any of this, this is just my assignment to be able to run on local.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • It sounds like you are running on Apple silicon M1, is the terminal running in Rosetta mode? – Beartech Nov 23 '22 at 17:04
  • Yep, getting the error in Rosetta also – DominikKraut Nov 24 '22 at 12:35
  • It looks like that gem is at version 2.2, not saying you should try to jump to that, but do you know what the dependency is? You might trying installing newer versions incrementally and see if bundle works. What does your Gemfile say? – Beartech Nov 24 '22 at 21:01
  • ah, I see the line now `prosopite was resolved to 0.2.1, which depends on pg_query`. I would try `gem install pg_query -v '1.3.0'` and increment the version until you get a successful install. Then retry `bundle install`. – Beartech Nov 24 '22 at 21:11
  • Thanks for the ideas but that also doesnt work, I tried installing newer/ olders versions of everything that seemed related and nothing – DominikKraut Nov 25 '22 at 10:16
  • I faced the same issue - after upgrading Ruby to `2.7.7` I got that error on installing `pg_query`. Nothing helped until I upgraded my MacOS to the later version (`12.6.3` in my case). Now it installs the `pg_query:1.3.0` without any issue. I have not idea how this could be connected. Perhaps it somehow relates to this topic https://bugs.ruby-lang.org/issues/19005 – shev.vadim.net Feb 11 '23 at 08:14

0 Answers0