thomax
thomax

Reputation: 9659

Trouble installing pg gem on OSX 10.10

I'm trying to install the pg gem on my system (macbook pro running 10.10, Postgresql 9.3.5_1, Ruby 1.9.3p547, Xcode v6.1 (6A1052c)) with this command:

ARCHFLAGS="-arch x86_64" gem install pg -- --with-pg-config=/usr/local/Cellar/postgresql/9.3.5_1/bin/pg_config

Returns this:

Building native extensions with: '--with-pg-config=/usr/local/Cellar/postgresql/9.3.5_1/bin/pg_config'
This could take a while...
ERROR:  Error installing pg:
    ERROR: Failed to build gem native extension.

    /Users/thomas/.rvm/rubies/ruby-1.9.3-p547/bin/ruby extconf.rb --with-pg-config=/usr/local/Cellar/postgresql/9.3.5_1/bin/pg_config
Using config values from /usr/local/Cellar/postgresql/9.3.5_1/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.

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/thomas/.rvm/rubies/ruby-1.9.3-p547/bin/ruby
    --with-pg
    --without-pg
    --with-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
/Users/thomas/.rvm/rubies/ruby-1.9.3-p547/lib/ruby/1.9.1/mkmf.rb:381:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
    from /Users/thomas/.rvm/rubies/ruby-1.9.3-p547/lib/ruby/1.9.1/mkmf.rb:461:in `try_link0'
    from /Users/thomas/.rvm/rubies/ruby-1.9.3-p547/lib/ruby/1.9.1/mkmf.rb:476:in `try_link'
    from extconf.rb:39:in `<main>'

extconf failed, exit code 1

Gem files will remain installed in /Users/thomas/.rvm/gems/ruby-1.9.3-p547/gems/pg-0.17.1 for inspection.
Results logged to /Users/thomas/.rvm/gems/ruby-1.9.3-p547/extensions/x86_64-darwin-13/1.9.1/pg-0.17.1/gem_make.out

What?

I'm pretty sure I have the developer tools installed:

xcode-select --print-path

Returns:

/Applications/Xcode.app/Contents/Developer

My mkmf.log file contains this:

"/usr/local/opt/gcc46/bin/gcc-4.6 -o conftest -I/Users/thomas/.rvm/rubies/ruby-1.9.3-p547/include/ruby-1.9.1/x86_64-darwin13.4.0 -I/Users/thomas/.rvm/rubies/ruby-1.9.3-p547/include/ruby-1.9.1/ruby/backward -I/Users/thomas/.rvm/rubies/ruby-1.9.3-p547/include/ruby-1.9.1 -I. -I/usr/local/Cellar/postgresql/9.3.5_1/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE   -I/usr/local/opt/libyaml/include -I/usr/local/opt/readline/include -I/usr/local/opt/libksba/include -I/usr/local/opt/openssl/include  -O3 -ggdb -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration  -fno-common -pipe conftest.c  -L. -L/Users/thomas/.rvm/rubies/ruby-1.9.3-p547/lib -L/usr/local/Cellar/postgresql/9.3.5_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/lib -L.  -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl/lib      -lruby.1.9.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 */

Doesn anyone have a clue about what's going on here? Any help would be greatly appreciated!

Upvotes: 1

Views: 1372

Answers (2)

Jack
Jack

Reputation: 3680

This solved my problem

First you should download the Postgres App (http://postgresapp.com/) and place it in your Applications folder. Extract and open it, now write this in your console.

gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/9.4/bin/pg_config

I wrote 9.4 because it was my latest version.

Upvotes: 6

thomax
thomax

Reputation: 9659

I finally solved this by ripping out all my rubies thus: rvm implode. Then I reinstalled rvm and Ruby 2.1.3 instead of 1.9.3. Sadly, I don't know exactly what the cause of the problem was, but I'm suspecting Ruby 1.9.3 does not install nicely with rvm on OSX 10.10.

Upvotes: 0

Related Questions