Just wanted to post a question I am facing issues installing gem install pg -v '0.21.0' for 2 projects in my system which is an M1 Mac, has anyone faced issues like this
This is the error I am getting
checking for pg_config_manual.h... yes
checking for PQconnectdb() in -lpq... no
checking for PQconnectdb() in -llibpq... no
checking for PQconnectdb() in -lms/libpq... no
Can't find the PostgreSQL client library (libpq)
> *** extconf.rb failed ***
Postgres is installed via Homebrew and libpq is also installed, I tried to point to the libpq when gem pg is being installed and try and fix the problem but that is not working too attaching the mkmf log for more details on the error and FYI Postgres is installed and I can also connect to it via terminal and other software. I tried a lot of answers from stack to no avail I am pretty new to Ruby and MAC any help will be great
More info but not sure if relevant had issues installing ruby versions 2.5.0 and 2.3.6 but that is now fixed (was showing as broken earlier so purged it and installed again after manually configuring openssl@1.0 to MAC) but when it was broken both pg and bundle install worked fine for one of my project but the Ruby 2.3.6 version failed to install
EDIT 1
ruby -v
ruby 2.3.6p384 (2017-12-14 revision 61254) [x86_64-darwin20]
which ruby
/Users/akshayvenugopal/.rvm/rubies/ruby-2.3.6/bin/ruby
rvm list
=* ruby-2.3.6 [ x86_64 ]
ruby-2.5.0 [ x86_64 ]
which openssl
/usr/local/opt/openssl@1.0/bin/openssl
postgres --version
postgres (PostgreSQL) 14.0
EDIT 2
have also had issues with nokogiri not sure if that's the issue
Let me know if you need anymore info any assistance will be greatly appreciated
MKMF Log
find_executable: checking for pg_config... -------------------- yes
--------------------
"gcc -o conftest -I/Users/akshayvenugopal/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0/x86_64-darwin20 -I/Users/akshayvenugopal/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0/ruby/backward -I/Users/akshayvenugopal/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0 -I. -I/opt/homebrew/opt/libpq/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -O3 -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wno-tautological-compare -Wno-parentheses-equality -Wno-constant-logical-operand -Wno-self-assign -Wunused-variable -Wimplicit-int -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -Wdivision-by-zero -Wdeprecated-declarations -Wmisleading-indentation -Wextra-tokens -fno-common -pipe conftest.c -L. -L/Users/akshayvenugopal/.rvm/rubies/ruby-2.5.0/lib -L/opt/homebrew/opt/libpq/lib -L. -fstack-protector -lruby.2.5.0 -lpthread -ldl -lobjc "
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main(int argc, char **argv)
4: {
5: return 0;
6: }
/* end */
"gcc -o conftest -I/Users/akshayvenugopal/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0/x86_64-darwin20 -I/Users/akshayvenugopal/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0/ruby/backward -I/Users/akshayvenugopal/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0 -I. -I/opt/homebrew/opt/libpq/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -O3 -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wno-tautological-compare -Wno-parentheses-equality -Wno-constant-logical-operand -Wno-self-assign -Wunused-variable -Wimplicit-int -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -Wdivision-by-zero -Wdeprecated-declarations -Wmisleading-indentation -Wextra-tokens -fno-common -pipe conftest.c -L. -L/Users/akshayvenugopal/.rvm/rubies/ruby-2.5.0/lib -L/opt/homebrew/opt/libpq/lib -L. -fstack-protector -lruby.2.5.0 -Wl,-rpath,/opt/homebrew/opt/libpq/lib -lpthread -ldl -lobjc "
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main() {return 0;}
/* end */
find_header: checking for libpq-fe.h... -------------------- yes
"gcc -E -I/Users/akshayvenugopal/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0/x86_64-darwin20 -I/Users/akshayvenugopal/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0/ruby/backward -I/Users/akshayvenugopal/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0 -I. -I/opt/homebrew/opt/libpq/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -O3 -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wno-tautological-compare -Wno-parentheses-equality -Wno-constant-logical-operand -Wno-self-assign -Wunused-variable -Wimplicit-int -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -Wdivision-by-zero -Wdeprecated-declarations -Wmisleading-indentation -Wextra-tokens -fno-common -pipe conftest.c -o conftest.i"
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: #include <libpq-fe.h>
/* end */
--------------------
find_header: checking for libpq/libpq-fs.h... -------------------- yes
"gcc -E -I/Users/akshayvenugopal/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0/x86_64-darwin20 -I/Users/akshayvenugopal/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0/ruby/backward -I/Users/akshayvenugopal/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0 -I. -I/opt/homebrew/opt/libpq/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -O3 -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wno-tautological-compare -Wno-parentheses-equality -Wno-constant-logical-operand -Wno-self-assign -Wunused-variable -Wimplicit-int -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -Wdivision-by-zero -Wdeprecated-declarations -Wmisleading-indentation -Wextra-tokens -fno-common -pipe conftest.c -o conftest.i"
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: #include <libpq/libpq-fs.h>
/* end */
--------------------
find_header: checking for pg_config_manual.h... -------------------- yes
"gcc -E -I/Users/akshayvenugopal/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0/x86_64-darwin20 -I/Users/akshayvenugopal/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0/ruby/backward -I/Users/akshayvenugopal/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0 -I. -I/opt/homebrew/opt/libpq/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -O3 -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wno-tautological-compare -Wno-parentheses-equality -Wno-constant-logical-operand -Wno-self-assign -Wunused-variable -Wimplicit-int -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -Wdivision-by-zero -Wdeprecated-declarations -Wmisleading-indentation -Wextra-tokens -fno-common -pipe conftest.c -o conftest.i"
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: #include <pg_config_manual.h>
/* end */
--------------------
have_library: checking for PQconnectdb() in -lpq... -------------------- no
"gcc -o conftest -I/Users/akshayvenugopal/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0/x86_64-darwin20 -I/Users/akshayvenugopal/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0/ruby/backward -I/Users/akshayvenugopal/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0 -I. -I/opt/homebrew/opt/libpq/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -O3 -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wno-tautological-compare -Wno-parentheses-equality -Wno-constant-logical-operand -Wno-self-assign -Wunused-variable -Wimplicit-int -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -Wdivision-by-zero -Wdeprecated-declarations -Wmisleading-indentation -Wextra-tokens -fno-common -pipe conftest.c -L. -L/Users/akshayvenugopal/.rvm/rubies/ruby-2.5.0/lib -L/opt/homebrew/opt/libpq/lib -L. -fstack-protector -Wl,-rpath,/opt/homebrew/opt/libpq/lib -lruby.2.5.0 -lpq -lpthread -ldl -lobjc "
ld: warning: ignoring file /opt/homebrew/opt/libpq/lib/libpq.dylib, building for macOS-x86_64 but attempting to link with file built for macOS-arm64
Undefined symbols for architecture x86_64:
"_PQconnectdb", referenced from:
_t in conftest-f3b0c7.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: #include <libpq-fe.h>
4:
5: /*top*/
6: extern int t(void);
7: int main(int argc, char **argv)
8: {
9: if (argc > 1000000) {
10: printf("%p", &t);
11: }
12:
13: return 0;
14: }
15: int t(void) { void ((*volatile p)()); p = (void ((*)()))PQconnectdb; return !p; }
/* end */
"gcc -o conftest -I/Users/akshayvenugopal/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0/x86_64-darwin20 -I/Users/akshayvenugopal/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0/ruby/backward -I/Users/akshayvenugopal/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0 -I. -I/opt/homebrew/opt/libpq/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -O3 -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wno-tautological-compare -Wno-parentheses-equality -Wno-constant-logical-operand -Wno-self-assign -Wunused-variable -Wimplicit-int -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -Wdivision-by-zero -Wdeprecated-declarations -Wmisleading-indentation -Wextra-tokens -fno-common -pipe conftest.c -L. -L/Users/akshayvenugopal/.rvm/rubies/ruby-2.5.0/lib -L/opt/homebrew/opt/libpq/lib -L. -fstack-protector -Wl,-rpath,/opt/homebrew/opt/libpq/lib -lruby.2.5.0 -lpq -lpthread -ldl -lobjc "
conftest.c:15:13: error: conflicting types for 'PQconnectdb'
extern void PQconnectdb();
^
/opt/homebrew/opt/libpq/include/libpq-fe.h:285:16: note: previous declaration is here
extern PGconn *PQconnectdb(const char *conninfo);
^
conftest.c:16:27: error: too few arguments to function call, single argument 'conninfo' was not specified
int t(void) { PQconnectdb(); return 0; }
~~~~~~~~~~~ ^
/opt/homebrew/opt/libpq/include/libpq-fe.h:285:16: note: 'PQconnectdb' declared here
extern PGconn *PQconnectdb(const char *conninfo);
^
2 errors generated.
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: #include <libpq-fe.h>
4:
5: /*top*/
6: extern int t(void);
7: int main(int argc, char **argv)
8: {
9: if (argc > 1000000) {
10: printf("%p", &t);
11: }
12:
13: return 0;
14: }
15: extern void PQconnectdb();
16: int t(void) { PQconnectdb(); return 0; }
/* end */
--------------------
have_library: checking for PQconnectdb() in -llibpq... -------------------- no
"gcc -o conftest -I/Users/akshayvenugopal/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0/x86_64-darwin20 -I/Users/akshayvenugopal/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0/ruby/backward -I/Users/akshayvenugopal/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0 -I. -I/opt/homebrew/opt/libpq/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -O3 -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wno-tautological-compare -Wno-parentheses-equality -Wno-constant-logical-operand -Wno-self-assign -Wunused-variable -Wimplicit-int -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -Wdivision-by-zero -Wdeprecated-declarations -Wmisleading-indentation -Wextra-tokens -fno-common -pipe conftest.c -L. -L/Users/akshayvenugopal/.rvm/rubies/ruby-2.5.0/lib -L/opt/homebrew/opt/libpq/lib -L. -fstack-protector -Wl,-rpath,/opt/homebrew/opt/libpq/lib -lruby.2.5.0 -llibpq -lpthread -ldl -lobjc "
ld: library not found for -llibpq
clang: error: linker command failed with exit code 1 (use -v to see invocation)
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: #include <libpq-fe.h>
4:
5: /*top*/
6: extern int t(void);
7: int main(int argc, char **argv)
8: {
9: if (argc > 1000000) {
10: printf("%p", &t);
11: }
12:
13: return 0;
14: }
15: int t(void) { void ((*volatile p)()); p = (void ((*)()))PQconnectdb; return !p; }
/* end */
"gcc -o conftest -I/Users/akshayvenugopal/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0/x86_64-darwin20 -I/Users/akshayvenugopal/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0/ruby/backward -I/Users/akshayvenugopal/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0 -I. -I/opt/homebrew/opt/libpq/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -O3 -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wno-tautological-compare -Wno-parentheses-equality -Wno-constant-logical-operand -Wno-self-assign -Wunused-variable -Wimplicit-int -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -Wdivision-by-zero -Wdeprecated-declarations -Wmisleading-indentation -Wextra-tokens -fno-common -pipe conftest.c -L. -L/Users/akshayvenugopal/.rvm/rubies/ruby-2.5.0/lib -L/opt/homebrew/opt/libpq/lib -L. -fstack-protector -Wl,-rpath,/opt/homebrew/opt/libpq/lib -lruby.2.5.0 -llibpq -lpthread -ldl -lobjc "
conftest.c:15:13: error: conflicting types for 'PQconnectdb'
extern void PQconnectdb();
^
/opt/homebrew/opt/libpq/include/libpq-fe.h:285:16: note: previous declaration is here
extern PGconn *PQconnectdb(const char *conninfo);
^
conftest.c:16:27: error: too few arguments to function call, single argument 'conninfo' was not specified
int t(void) { PQconnectdb(); return 0; }
~~~~~~~~~~~ ^
/opt/homebrew/opt/libpq/include/libpq-fe.h:285:16: note: 'PQconnectdb' declared here
extern PGconn *PQconnectdb(const char *conninfo);
^
2 errors generated.
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: #include <libpq-fe.h>
4:
5: /*top*/
6: extern int t(void);
7: int main(int argc, char **argv)
8: {
9: if (argc > 1000000) {
10: printf("%p", &t);
11: }
12:
13: return 0;
14: }
15: extern void PQconnectdb();
16: int t(void) { PQconnectdb(); return 0; }
/* end */
--------------------
have_library: checking for PQconnectdb() in -lms/libpq... -------------------- no
"gcc -o conftest -I/Users/akshayvenugopal/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0/x86_64-darwin20 -I/Users/akshayvenugopal/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0/ruby/backward -I/Users/akshayvenugopal/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0 -I. -I/opt/homebrew/opt/libpq/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -O3 -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wno-tautological-compare -Wno-parentheses-equality -Wno-constant-logical-operand -Wno-self-assign -Wunused-variable -Wimplicit-int -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -Wdivision-by-zero -Wdeprecated-declarations -Wmisleading-indentation -Wextra-tokens -fno-common -pipe conftest.c -L. -L/Users/akshayvenugopal/.rvm/rubies/ruby-2.5.0/lib -L/opt/homebrew/opt/libpq/lib -L. -fstack-protector -Wl,-rpath,/opt/homebrew/opt/libpq/lib -lruby.2.5.0 -lms/libpq -lpthread -ldl -lobjc "
ld: library not found for -lms/libpq
clang: error: linker command failed with exit code 1 (use -v to see invocation)
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: #include <libpq-fe.h>
4:
5: /*top*/
6: extern int t(void);
7: int main(int argc, char **argv)
8: {
9: if (argc > 1000000) {
10: printf("%p", &t);
11: }
12:
13: return 0;
14: }
15: int t(void) { void ((*volatile p)()); p = (void ((*)()))PQconnectdb; return !p; }
/* end */
"gcc -o conftest -I/Users/akshayvenugopal/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0/x86_64-darwin20 -I/Users/akshayvenugopal/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0/ruby/backward -I/Users/akshayvenugopal/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0 -I. -I/opt/homebrew/opt/libpq/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -O3 -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wno-tautological-compare -Wno-parentheses-equality -Wno-constant-logical-operand -Wno-self-assign -Wunused-variable -Wimplicit-int -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -Wdivision-by-zero -Wdeprecated-declarations -Wmisleading-indentation -Wextra-tokens -fno-common -pipe conftest.c -L. -L/Users/akshayvenugopal/.rvm/rubies/ruby-2.5.0/lib -L/opt/homebrew/opt/libpq/lib -L. -fstack-protector -Wl,-rpath,/opt/homebrew/opt/libpq/lib -lruby.2.5.0 -lms/libpq -lpthread -ldl -lobjc "
conftest.c:15:13: error: conflicting types for 'PQconnectdb'
extern void PQconnectdb();
^
/opt/homebrew/opt/libpq/include/libpq-fe.h:285:16: note: previous declaration is here
extern PGconn *PQconnectdb(const char *conninfo);
^
conftest.c:16:27: error: too few arguments to function call, single argument 'conninfo' was not specified
int t(void) { PQconnectdb(); return 0; }
~~~~~~~~~~~ ^
/opt/homebrew/opt/libpq/include/libpq-fe.h:285:16: note: 'PQconnectdb' declared here
extern PGconn *PQconnectdb(const char *conninfo);
^
2 errors generated.
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: #include <libpq-fe.h>
4:
5: /*top*/
6: extern int t(void);
7: int main(int argc, char **argv)
8: {
9: if (argc > 1000000) {
10: printf("%p", &t);
11: }
12:
13: return 0;
14: }
15: extern void PQconnectdb();
16: int t(void) { PQconnectdb(); return 0; }
/* end */
--------------------