3

I was trying to install rails with database postgresql and got an error:

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

    /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb 
checking for pg_config... yes
Using config values from /usr/local/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
        --without-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=/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby
        --with-pg
        --without-pg
        --enable-windows-cross
        --disable-windows-cross
        --with-pg-config
        --without-pg-config
        --with-pg_config
        --without-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}/
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/tmpdir.rb:92:in `mktmpdir': parent directory is world writable but not sticky (ArgumentError)
        from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/mkmf.rb:510:in `try_link0'
        from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/mkmf.rb:534:in `try_link'
        from extconf.rb:36:in `<main>'


Gem files will remain installed in /tmp/bundler20150325-70824-ipx8vh/pg-0.18.1/gems/pg-0.18.1 for inspection.
Results logged to /tmp/bundler20150325-70824-ipx8vh/pg-0.18.1/gems/pg-0.18.1/ext/gem_make.out
An error occurred while installing pg (0.18.1), and Bundler cannot continue.
Make sure that `gem install pg -v '0.18.1'` succeeds before bundling.

What can be done to fix this?

egdmitry
  • 2,071
  • 15
  • 18
Ade Yahya
  • 717
  • 5
  • 6
  • The message says in part "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 should probably check that file. Make sure you have the postgresql libs (and likely postgresql-dev libs) installed. If they are in a non-standard location, you will need to specify the location via the various --with-opt-* options. – KenB Mar 24 '15 at 19:54

2 Answers2

1

thanks, but i have solution and the problem is 32bit vs.64 bit compatibility.

ARCHFLAGS='-arch x86_64' gem install pg
Ade Yahya
  • 717
  • 5
  • 6
0

Checkout this link: stackoverflow.com/questions/9668753.

This always works for me, but I also download postgres first and move to Applications directory: Postgress.app

Install Homebrew

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

If you're not sure if you have Homebrew run:

brew -v 

If installed, you should get current version, such as Hombrew 0.9.5

then run:

brew install postgresql

finally:

bundle install
Community
  • 1
  • 1
user3361996
  • 373
  • 3
  • 14