2

I tried out rubymine for the first time and changed the Postgresql settings and now the gem won't install. Below is the copy of the error after trying to install the gem. The below was run after I deleted the Rubymine app and the files it created.

Aris-MacBook-Pro:~ arikalmen$ gem install pg
Building native extensions.  This could take a while...
ERROR:  Error installing pg:
    ERROR: Failed to build gem native extension.

    current directory: /Users/arikalmen/.rvm/gems/ruby-2.4.1/gems/pg-0.21.0/ext
/Users/arikalmen/.rvm/rubies/ruby-2.4.1/bin/ruby -r ./siteconf20171221-20772-masvtl.rb extconf.rb
checking for pg_config... no
No pg_config... trying anyway. If building fails, please try again with
 --with-pg-config=/path/to/pg_config
checking for libpq-fe.h... no
Can't find the 'libpq-fe.h header
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
    --with-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/Users/arikalmen/.rvm/rubies/ruby-2.4.1/bin/$(RUBY_BASE_NAME)
    --with-pg
    --without-pg
    --enable-windows-cross
    --disable-windows-cross
    --with-pg-config
    --without-pg-config
    --with-pg_config
    --without-pg_config
    --with-pg-dir
    --without-pg-dir
    --with-pg-include
    --without-pg-include=${pg-dir}/include
    --with-pg-lib
    --without-pg-lib=${pg-dir}/lib

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /Users/arikalmen/.rvm/gems/ruby-2.4.1/extensions/x86_64-darwin-17/2.4.0/pg-0.21.0/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /Users/arikalmen/.rvm/gems/ruby-2.4.1/gems/pg-0.21.0 for inspection.
Results logged to /Users/arikalmen/.rvm/gems/ruby-2.4.1/extensions/x86_64-darwin-17/2.4.0/pg-0.21.0/gem_make.out
Aris-MacBook-Pro:~ arikalmen$

The pasted below was in the before mentioned mkmf.log

/Users/arikalmen/.rvm/gems/ruby-2.4.1/extensions/x86_64-darwin-17/2.4.0/pg-0.21.0/gem_make.out

ind_executable: checking for pg_config... -------------------- no

--------------------

find_header: checking for libpq-fe.h... -------------------- no

"gcc -o conftest -I/Users/arikalmen/.rvm/rubies/ruby-2.4.1/include/ruby-2.4.0/x86_64-darwin17 -I/Users/arikalmen/.rvm/rubies/ruby-2.4.1/include/ruby-2.4.0/ruby/backward -I/Users/arikalmen/.rvm/rubies/ruby-2.4.1/include/ruby-2.4.0 -I.  -I/usr/local/opt/libyaml/include -I/usr/local/opt/readline/include -I/usr/local/opt/libksba/include -I/usr/local/opt/openssl@1.1/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT   -O3 -fno-fast-math -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 -Wextra-tokens  -fno-common -pipe conftest.c  -L. -L/Users/arikalmen/.rvm/rubies/ruby-2.4.1/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl@1.1/lib -L. -fstack-protector -L/usr/local/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl@1.1/lib     -lruby.2.4.1  -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 -E -I/Users/arikalmen/.rvm/rubies/ruby-2.4.1/include/ruby-2.4.0/x86_64-darwin17 -I/Users/arikalmen/.rvm/rubies/ruby-2.4.1/include/ruby-2.4.0/ruby/backward -I/Users/arikalmen/.rvm/rubies/ruby-2.4.1/include/ruby-2.4.0 -I.  -I/usr/local/opt/libyaml/include -I/usr/local/opt/readline/include -I/usr/local/opt/libksba/include -I/usr/local/opt/openssl@1.1/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT   -O3 -fno-fast-math -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 -Wextra-tokens  -fno-common -pipe  conftest.c -o conftest.i"
conftest.c:3:10: fatal error: 'libpq-fe.h' file not found
#include <libpq-fe.h>
         ^~~~~~~~~~~~
1 error generated.
checked program was:
"mkmf.log" [readonly] 31L, 2722C
Ari Kalmen
  • 33
  • 7

3 Answers3

1

First, install the missing library:

brew install libpqxx

then follow the steps in this LINK

Chetan Datta
  • 447
  • 9
  • 19
  • I think I'm having conflict between the Graphical installer by BigSQL that i installed and the Postgres.app found on the download pag3 [link](https://www.postgresql.org/download/macosx/) I removed the Graphical installer from my apps, but I sense it's still there because the default postgresql port(5432) is still being occupied. Figured that out from this question. [link](https://stackoverflow.com/questions/15100368/postgresql-port-confusion-5433-or-5432) – Ari Kalmen Dec 22 '17 at 03:39
0

The above error message says:

checking for libpq-fe.h... no

Can't find the 'libpq-fe.h header

Installing this should fix your error.

common sense
  • 3,775
  • 6
  • 22
  • 31
0

You need specify ARCHFLAG, Try this: sudo ARCHFLAGS="-arch x86_64" gem install pg

Daniel
  • 869
  • 2
  • 7
  • 19