5

I used RVM to install Ruby-2.1.5 and ran bundle again. Now the pg gem won't install and I get this error:

gem install pg -v '0.17.1' -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/9.3/bin/pg_config
Building native extensions with: '--with-pg-config=/Applications/Postgres.app/Contents/Versions/9.3/bin/pg_config'
This could take a while...
ERROR:  Error installing pg:
    ERROR: Failed to build gem native extension.

    /Users/diego/.rvm/rubies/ruby-2.1.5/bin/ruby -r ./siteconf20141120-33258-108chh6.rb extconf.rb --with-pg-config=/Applications/Postgres.app/Contents/Versions/9.3/bin/pg_config
Using config values from /Applications/Postgres.app/Contents/Versions/9.3/bin/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()... yes
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... yes
checking for PGRES_SINGLE_TUPLE in libpq-fe.h... yes
checking for PG_DIAG_TABLE_NAME in libpq-fe.h... yes
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=" clean

make "DESTDIR="
compiling gvl_wrappers.c
compiling pg.c
compiling pg_connection.c
compiling pg_errors.c
compiling pg_result.c
linking shared-object pg_ext.bundle
couldn't understand kern.osversion `14.0.0'
ld: warning: directory not found for option '-L/Users/mpapis/.sm/pkg/active/lib'
ld: -rpath can only be used when targeting Mac OS X 10.5 or later
collect2: ld returned 1 exit status
make: *** [pg_ext.bundle] Error 1

make failed, exit code 2

I've updated XCode to version 6.1 via the App Store. I reinstalled gcc and applegcc-4.2 via homebrew. I also reinstall Postgres.app. I've tried the suggested solutions here and here to no avail.

Anybody have any idea what to try next? For now I'm just reverting to Ruby-2.1.4 where pg installs fine.

Community
  • 1
  • 1
DiegoSalazar
  • 13,361
  • 2
  • 38
  • 55
  • 1
    Have you tried `brew update` to update the formulae and Homebrew itself and `rvm cleanup all` to delete stale ruby folders...? – konyak Nov 26 '14 at 21:07
  • Native extensions usually have dependencies on the system tools available. Right now the dependency must be furnished by xode-commandline-tools. Try,`xcode-select --install `. It seems to be pretty similar to http://stackoverflow.com/q/26486163 – MIdhun Krishna Nov 27 '14 at 13:20
  • I tried brew update and rvm cleanup. Xcode select was the first thing I tried it just exits with a message saying already installed, update via Software Update. Did that afterwards. Still same error :( – DiegoSalazar Nov 27 '14 at 18:28
  • Have you tried the 0.18.0.pre release of PG? – Automatico Nov 28 '14 at 11:46
  • What source is that under? I get an error trying to gem install that version: `gem install pg -v '0.18.0.pre' ERROR: Could not find a valid gem 'pg' (= 0.18.0.pre) in any repository ERROR: Possible alternatives: pg` – DiegoSalazar Nov 28 '14 at 16:41
  • You have the postgres app install and you install postgres via homebrew -- why? – Anthony Nov 29 '14 at 14:23
  • I tried both ways in a desperate attempt to get it to work as I've exhausted everything I've found on the webs about this error. – DiegoSalazar Nov 29 '14 at 17:18
  • You can't do both, they will conflict on the port. Remove the app, `brew uninstall postgres`, check to make sure no other posgres processes are running `ps aux | grep postgres` and if all is ok, reinstall with homebrew. – Anthony Nov 29 '14 at 20:21
  • Have you checked this post? http://stackoverflow.com/questions/23429145/error-failed-to-build-gem-native-extension-ruby-extconf-rb-mac-osx – tokhi Dec 01 '14 at 14:10

1 Answers1

13

If you set MACOSX_DEPLOYMENT_TARGET=10.9 in your environment prior to compiling the pg gem, the shared object linking should work properly.

Sasha
  • 485
  • 3
  • 6