0

I'm trying to run "bundle install", the only database gem I have in my Gemfile is pg, so I'm getting the following errors.

bundle install
Fetching gem metadata from https://rubygems.org/...........
Fetching additional metadata from https://rubygems.org/..
Resolving dependencies...
...

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb --with-pg-config=/Applications/Postgres.app/Contents/MacOS/bin/pg_config
Using config values from /Applications/Postgres.app/Contents/MacOS/bin/pg_config
sh: /Applications/Postgres.app/Contents/MacOS/bin/pg_config: No such file or directory
sh: /Applications/Postgres.app/Contents/MacOS/bin/pg_config: No such file or directory
checking for libpq-fe.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
clang: error: unknown argument: '-multiply_definedsuppress' [-Wunused-command-line-argument-hard-error-in-future]
clang: note: this will be a hard error (cannot be downgraded to a warning) in the future
make: *** [pg_ext.bundle] Error 1

make failed, exit code 2

Gem files will remain installed in /Users/marklalich/.bundler/tmp/14076/gems/pg-0.17.1 for inspection.
Results logged to /Users/marklalich/.bundler/tmp/14076/extensions/universal-darwin-13/2.0.0/pg-0.17.1/gem_make.out
An error occurred while installing pg (0.17.1), and Bundler cannot continue.
Make sure that `gem install pg -v '0.17.1'` succeeds before bundling.

I can't find anything online, please someone help!

Thanks!!

Darkmatter5
  • 1,189
  • 3
  • 12
  • 19
  • 1
    How did you install postgres. You can install postgres using postgres app from http://postgresapp.com/. Place it into application directory and configure the path of pg gem. gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/9.3/bin/pg_config – user944938 Apr 09 '14 at 16:47
  • possible duplicate of [Ruby Gem install Json fails on Mavericks and Xcode 5.1 - unknown argument: '-multiply\_definedsuppress'](http://stackoverflow.com/questions/22352838/ruby-gem-install-json-fails-on-mavericks-and-xcode-5-1-unknown-argument-mul) – Nakilon Apr 20 '14 at 01:15

2 Answers2

2

I had the same problem and the fix for me was setting the bundle config settings first:

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

Don't get hung up on the pg gem. Doing the bundle install after doing this bundle config fixed the "make failed" problem for me.

For reference, This was the answer that helped https://stackoverflow.com/a/9235107/3546680 but it was user944938's answer that gave me the correct path to put in. Thanks and hope it helps someone else too!

Community
  • 1
  • 1
paninapress
  • 491
  • 4
  • 6
0

How did you install postgres. You can install postgres using postgres app from postgresapp.com. Place it into application directory and configure the path of pg gem. gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/9.3/bin/pg_config

user944938
  • 990
  • 7
  • 9
  • I did install postgres with the app. Will I have to use this command everything I create a new rails app? – Darkmatter5 Apr 09 '14 at 17:49
  • Not required because your gem will be installed, for new apps it will be about fetching the existing gem. – user944938 Apr 09 '14 at 18:03
  • I ran that command and still get the same error. I also verified the path you provided is correct and it is, but I'm still getting the following error. ERROR: Error installing pg: ERROR: Failed to build gem native extension. – Darkmatter5 Apr 09 '14 at 18:27
  • I think you are having issues with c headers? Can you post that error msg.. Also did you replace the version number with your 9.3 with your Postgres verion? – user944938 Apr 09 '14 at 18:28
  • 9.3 is my version in the app, so I used it. – Darkmatter5 Apr 09 '14 at 18:33
  • I cant see the stacktrace here... may be a gist? or pastie? – user944938 Apr 09 '14 at 18:34
  • 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 clang: error: unknown argument: '-multiply_definedsuppress' [-Wunused-command-line-argument-hard-error-in-future] clang: note: this will be a hard error (cannot be downgraded to a warning) in the future make: *** [pg_ext.bundle] Error 1 make failed, exit code 2 – Darkmatter5 Apr 09 '14 at 18:35
  • This is unreadable. The error is above in the original message. You're right it has to do with the .c files. – Darkmatter5 Apr 09 '14 at 18:37
  • try doing this gem install pg -- --with-pg-include='/Applications/Postgres.app/Contents/Versions/9.3/include/' – user944938 Apr 09 '14 at 18:37
  • Can you also check and let me know if this path is available at your end? /Applications/Postgres.app/Contents/Versions/9.3/bin/pg_config – user944938 Apr 09 '14 at 18:38
  • so modify your command to gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/9.3/bin/pg_config .. give that a shot and let me know – user944938 Apr 09 '14 at 18:40
  • It also gave me the same error. Just so you know, I'm having to use sudo each time, can this cause a problem? – Darkmatter5 Apr 09 '14 at 18:43
  • Im not sure.. what is the version of your postgres gem and are using mavericks by any chance.. – user944938 Apr 09 '14 at 18:45
  • Yes mavericks. In my gemfile I'm just using gem pg, so I think just the most recent. I haven't specified a version. – Darkmatter5 Apr 09 '14 at 18:47
  • does your folder name have any number associated, Postgres9.3 ? – user944938 Apr 09 '14 at 18:47
  • to confirm, did you place these configurations in your .bundle? – user944938 Apr 09 '14 at 18:49
  • BUNDLE_BUILD__PG: --with-pg-config=/Applications/Postgres.app/Contents/Versions/9.3/bin/pg_config BUNDLE_BUILD__EXAMPLE_GEM: --other-configs BUNDLE_BUILD__OTHER_EXAMPLE_GEM: --other-configs should be in your /Users//.bundle/config – user944938 Apr 09 '14 at 18:50
  • I found the following link. It sounds like XCode 5.1 is causing the issue. http://stackoverflow.com/questions/22312583/cant-install-mysql-gem-on-os-x I'm just not sure how to fix it. It says to rebuild Ruby, but I'm not sure how. – Darkmatter5 Apr 09 '14 at 18:53
  • Hmm... As try run this from the link I gathered they are using arch flags so figured this could be a possibility.. Lets try this and if it does not workout we can try to rebuild... ARCHFLAGS="-arch x86_64" gem install pg -- --with-pg-config=/Library/PostgreSQL/9.3/bin/pg_config – user944938 Apr 09 '14 at 18:58
  • I found a link @ http://stackoverflow.com/questions/22352838/ruby-gem-install-json-fails-on-mavericks-and-xcode-5-1-unknown-argument-mul?lq=1 to get ruby reinstalled. After doing this and then running sudo gem install pg, it worked. I think I'm good! – Darkmatter5 Apr 09 '14 at 19:00