0

I am trying to write a ruby program to connect to PostgreSQL database. Since, I will be using the pg and pg_query ruby extension, I am trying to install them by running:

gem install pg

or

gem install pg -- --with-pg-config=/Library/PostgreSQL/12/bin/pg_config and am getting the following error:

This could take a while...
ERROR:  Error installing pg:
    ERROR: Failed to build gem native extension.

    /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby extconf.rb --with-pg-config=/Library/PostgreSQL/12/bin/pg_config
Using config values from /Library/PostgreSQL/12/bin/pg_config
*** 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.

.

.
.
.
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:467:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
    from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:546:in `block in try_link0'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/tmpdir.rb:93:in `mktmpdir'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:543:in `try_link0'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:570:in `try_link'
    from extconf.rb:40:in `<main>'

Can someone help me get this issue resolved?

FYI - I am new to macOS and Ruby.

Thanks

P_Ar
  • 377
  • 2
  • 9
  • 25
  • 2
    Does this answer your question? [Gem installation error: You have to install development tools first](https://stackoverflow.com/q/27768420/895789) – Alter Lagos Mar 02 '21 at 01:56
  • Thank you guys. I actually had to install a new version of ruby (3.0) on my macBook and everything started working after that :-) – P_Ar Mar 05 '21 at 03:03

0 Answers0