ERROR: Failed to build gem native extension on Mavericks
Asked Answered
R

11

46

I'm attempting to run bundle in my Rails project on OSX 10.9. It fails when getting to the pg gem with this error:

Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

    /Users/kyledecot/.rvm/rubies/ruby-2.0.0-p247/bin/ruby 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... yes
checking for libpq/libpq-fs.h... yes
checking for pg_config_manual.h... yes
checking for PQconnectdb() in -lpq... yes
checking for PQconnectionUsedPassword()... yes
checking for PQisthreadsafe()... yes
checking for PQprepare()... yes
checking for PQexecParams()... yes
checking for PQescapeString()... yes
checking for PQescapeStringConn()... yes
checking for PQescapeLiteral()... yes
checking for PQescapeIdentifier()... yes
checking for PQgetCancel()... yes
checking for lo_create()... yes
checking for pg_encoding_to_char()... yes
checking for pg_char_to_encoding()... yes
checking for PQsetClientEncoding()... yes
checking for PQlibVersion()... yes
checking for PQping()... yes
checking for PQsetSingleRowMode()... yes
checking for rb_encdb_alias()... yes
checking for rb_enc_alias()... no
checking for rb_thread_call_without_gvl()... yes
checking for rb_thread_call_with_gvl()... yes
checking for rb_thread_fd_select()... yes
checking for rb_w32_wrap_io_handle()... no
checking for PGRES_COPY_BOTH in libpq-fe.h... no
checking for PGRES_SINGLE_TUPLE in libpq-fe.h... no
checking for PG_DIAG_TABLE_NAME in libpq-fe.h... no
checking for struct pgNotify.extra in libpq-fe.h... yes
checking for unistd.h... yes
checking for ruby/st.h... yes
creating extconf.h
creating Makefile

make "DESTDIR="
compiling gvl_wrappers.c
clang: warning: argument unused during compilation: '-fno-fast-math'
compiling pg.c
clang: warning: argument unused during compilation: '-fno-fast-math'
pg.c:272:9: warning: implicit declaration of function 'PQlibVersion' is invalid in C99 [-Wimplicit-function-declaration]
        return INT2NUM(PQlibVersion());
               ^
In file included from pg.c:48:
In file included from ./pg.h:17:
In file included from /Users/kyledecot/.rvm/rubies/ruby-2.0.0-p247/include/ruby-2.0.0/ruby.h:33:
/Users/kyledecot/.rvm/rubies/ruby-2.0.0-p247/include/ruby-2.0.0/ruby/ruby.h:1167:21: note: instantiated from:
# define INT2NUM(v) INT2FIX((int)(v))
                    ^
pg.c:272:9: note: instantiated from:
        return INT2NUM(PQlibVersion());
               ^
pg.c:272:17: note: instantiated from:
        return INT2NUM(PQlibVersion());
                       ^
pg.c:375:48: error: use of undeclared identifier 'PQPING_OK'
        rb_define_const(rb_mPGconstants, "PQPING_OK", INT2FIX(PQPING_OK));
                                                      ^
pg.c:375:56: note: instantiated from:
        rb_define_const(rb_mPGconstants, "PQPING_OK", INT2FIX(PQPING_OK));
                                                              ^
pg.c:377:52: error: use of undeclared identifier 'PQPING_REJECT'
        rb_define_const(rb_mPGconstants, "PQPING_REJECT", INT2FIX(PQPING_REJECT));
                                                          ^
pg.c:377:60: note: instantiated from:
        rb_define_const(rb_mPGconstants, "PQPING_REJECT", INT2FIX(PQPING_REJECT));
                                                                  ^
pg.c:379:57: error: use of undeclared identifier 'PQPING_NO_RESPONSE'
        rb_define_const(rb_mPGconstants, "PQPING_NO_RESPONSE", INT2FIX(PQPING_NO_RESPONSE));
                                                               ^
pg.c:379:65: note: instantiated from:
        rb_define_const(rb_mPGconstants, "PQPING_NO_RESPONSE", INT2FIX(PQPING_NO_RESPONSE));
                                                                       ^
pg.c:381:56: error: use of undeclared identifier 'PQPING_NO_ATTEMPT'
        rb_define_const(rb_mPGconstants, "PQPING_NO_ATTEMPT", INT2FIX(PQPING_NO_ATTEMPT));
                                                              ^
pg.c:381:64: note: instantiated from:
        rb_define_const(rb_mPGconstants, "PQPING_NO_ATTEMPT", INT2FIX(PQPING_NO_ATTEMPT));
                                                                      ^
1 warning and 4 errors generated.
make: *** [pg.o] Error 1


Gem files will remain installed in /Users/kyledecot/.rvm/gems/ruby-2.0.0-p247@skateboxes/gems/pg-0.17.0 for inspection.
Results logged to /Users/kyledecot/.rvm/gems/ruby-2.0.0-p247@skateboxes/gems/pg-0.17.0/ext/gem_make.out

An error occurred while installing pg (0.17.0), and Bundler cannot continue.
Make sure that `gem install pg -v '0.17.0'` succeeds before bundling.
Rowan answered 24/10, 2013 at 14:40 Comment(0)
H
54

Also make sure that you've upgraded Xcode to re-install command line tools on Mavericks. In terminal type:

xcode-select --install

Then follow the prompts.

Hazlett answered 24/10, 2013 at 15:59 Comment(4)
This doesn't work for me. I get "Can't install the software because it is not currently available from the Software Update server." From the CLI installer. Further research showed that Xcode 5 comes default with CLI tools. Sayanee's answer worked for me.Bobbette
@JosephJuhnke I had the same issue. You can download and install manually from the Apple website. That worked for me.developer.apple.com/downloads/…Quartet
Oddly, I recall that I had installed this software recently, but running the installer again as prescribed, fixed my issue. Thanks!Antiphonal
I had Xcode installed but had not agreed to the license. Running sudo xcodebuild -license solved the problem.Dumbarton
A
47

For me it worked when I did:

brew install postgresql
Adelbert answered 24/11, 2013 at 20:19 Comment(2)
sometimes you need to gem uninstall pg after you brew install postgresqlGoahead
worked for me! looks like using brew fixes the issueQuinary
U
27

this worked for me with Mavericks and the Postgresapp:

gem install pg -v '0.17.0' -- --with-pg-config=/Applications/Postgres93.app/Contents/MacOS/bin/pg_config
Uretic answered 13/12, 2013 at 5:8 Comment(2)
worked for me too, for those copying this command pay attention to your Postgres.app name in the pathUrial
Postgres/Contents/Versions/9.3/bin/pg_config for anyone installing with OS X Postgres appLucindalucine
S
14

Try using the --with-pg-config argument:

bundle config build.pg --with-pg-config=/usr/pgsql-9.1/bin/pg_config

To show the path of the pg_config:

which pg_config

For Ubuntu users:

sudo apt-get install postgresql
sudo apt-get install libpq-dev

Then:

bundle install
Solidarity answered 24/10, 2013 at 14:55 Comment(0)
A
12

For me using Mavericks, Rails 3.2.13, Ruby 2.0.0-p247, PostgreSQL 9.1, I needed todo this:

gem install pg -v '0.15.1' -- --with-pg-config=/Library/PostgreSQL/9.1/bin/pg_config
Alialia answered 4/11, 2013 at 15:50 Comment(1)
thanks, this worked for me to with version 9.3.1 on osx mavericks finalMealtime
O
3

This worked for me on Mac OS X 10.9.3 and Postgres.app version 9.3.4.2:

1) Install Postgres.app

2) bundle config build.pg --with-pg-config=/Applications/Postgres.app/Contents/Versions/9.3/bin/pg_config

3) gem install pg -v '0.17.1'

4) bundle install

Oxbow answered 29/6, 2014 at 1:57 Comment(1)
What worked for me was gem install pg -v '0.18.1' -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/9.3/bin/pg_configDiacid
C
3

I've just got it running by doing

ARCHFLAGS="-arch x86_64" gem install pg

after installing posgres using brew

Corby answered 8/7, 2014 at 17:32 Comment(0)
J
3

When i try to install

apt-get install libpq-dev

Failed to install, unmet dependencies problem, to solve

apt-get remove libpq5

then install

apt-get install libpq-dev

Finally solved the gem pg issue.

Jaffe answered 2/9, 2015 at 7:52 Comment(0)
D
2

The following worked for me:

gem install pg -v '0.18.1' -- --with-pg config=/Library/PostgreSQL/9.3/bin/pg_config

Dormitory answered 20/2, 2015 at 14:32 Comment(0)
V
2

You have to configure pg with your current version I used mine 9.4 version on Yosemite. Here is the following command

bundle config build.pg --with-pg-config=/Applications/Postgres.app/Contents/Versions/9.4/bin/pg_config 

You should use your own version

bundle config build.pg --with-pg-config=/Applications/Postgres.app/Contents/Versions/(YOUR POSTGRES VERSION)/bin/pg_config 

then do

bundle install
Vannessavanni answered 26/4, 2015 at 19:24 Comment(0)
B
0

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

I was able to fix this error by rolling back to Ruby v2.0.0. I was running Ruby 2.1.1, which is not supported for this debugger version. Be sure to check your ruby version if you run into this issue as well.

Bowerman answered 6/8, 2015 at 18:42 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.