I can't install the pg gem when I run bundle, or when I try to install it separately. The error I get is: "could not create Makefile." I'm running Mountain Lion, have Xcode installed, and have command line tools installed. I also have Postregsql installed via homebrew.
I believe the error is because I can't create the makefile, which has surfaced as the error preventing me from doing other things.
The full error I get is below.
This error happens during the bundle. The other gems are installed fine, or are marked as using, then this error terminates the bundle while installing pg (0.14.1) with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb
checking for pg_config... yes
Using config values from /usr/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... no
checking for PQconnectdb() in -llibpq... no
checking for PQconnectdb() in -lms/libpq... no
Can't find the PostgreSQL client library (libpq)
*** 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/1.8/usr/bin/ruby
--with-pg
--without-pg
--with-pg-dir
--without-pg-dir
--with-pg-include
--without-pg-include=${pg-dir}/include
--with-pg-lib
--without-pg-lib=${pg-dir}/lib
--with-pg-config
--without-pg-config
--with-pg_config
--without-pg_config
--with-pqlib
--without-pqlib
--with-libpqlib
--without-libpqlib
--with-ms/libpqlib
--without-ms/libpqlib
Gem files will remain installed in /Users/ericavirtue/.bundler/tmp/75812/gems/pg-0.14.1 for inspection.
Results logged to /Users/ericavirtue/.bundler/tmp/75812/gems/pg-0.14.1/ext/gem_make.out
An error occurred while installing pg (0.14.1), and Bundler cannot continue.
Make sure that `gem install pg -v '0.14.1'` succeeds before bundling.
I'm really at a loss for what to do here. I've been working on this for two days.
EDIT:
So when trying to find the path to implement the solution Christian Rapp suggested I found this recommendation: sudo env ARCHFLAGS="-arch x86_64" gem install pg which worked to install pg. Unfortunately I'm getting errors when I try to run rails s, rake db:create:all, or rake db:migrate. I'll create a separate question to trace those problems down ...
I am not using homebrew on MacOS but where does it install libpq? MacPorts is using /opt and your configure script does not know anything about this. The error messages is quite informative just provide the path with something like
gem install pg -- --with-libpqlib=/opt/...
May be you have to use another flag to provide the necessary Informations
The error is this:
Can't find the PostgreSQL client library (libpq)
You'll need to install PostreSQL (I recommend using Homebrew, but there are probably other downloads available) and try to install the gem again.
"Can't find the PostgreSQL client library (libpq)"
This is the reason your makefile can't be created. Your Postgres libraries, specifically libpq can't be found on your path. I see you installed with Homebrew. I don't use homebrew so I don't know if it sets the path for you.
Related
Ive been trying out Rubymine for a small rails project and would really like the debugging to work.
The project is a rails API and uses Postgres running on my Mac with El Capitan.
The problem i have is Rubymine is complaining of 'No Rails found in SDK'
I thought the solution to this was to run bundle install from the Rubymine menu.
However that consistently fails at installing pg:
....
Using hashie 3.4.3
Using multi_json 1.11.2
Using multi_xml 0.5.5
Using newrelic_rpm 3.14.2.312
Installing pg 0.18.4 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby -r ./siteconf20160617-92261-aw26bh.rb extconf.rb
checking for pg_config... yes
Using config values from /usr/local/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... no
checking for PQconnectdb() in -llibpq... no
checking for PQconnectdb() in -lms/libpq... no
Can't find the PostgreSQL client library (libpq)
*** 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}/
--with-pqlib
--without-pqlib
--with-libpqlib
--without-libpqlib
--with-ms/libpqlib
--without-ms/libpqlib
extconf failed, exit code 1
...
Using faraday 0.9.2
Using hashie-forbidden_attributes 0.1.1
Using httparty 0.13.7
An error occurred while installing pg (0.18.4), and Bundler cannot continue.
Make sure that `gem install pg -v '0.18.4'` succeeds before bundling.
I have tried numerous of the other solutions on stack overflow including:
Bundler::GemNotFound: Could not find rake-10.3.2 in any of the sources
An error occurred while installing pg (0.17.1), and Bundler cannot continue
and have installed postgres on my machine (i think) using the app and brew.
Any ideas for making this work would be greatly appreciated!
I don't think the error is RubyMine-related; I think it's system-related.
That is, if you do gem install pg on the command line, I suspect you'll get the same error.
I use rvm and it just works. It installs the necessary system libraries. (That said, others have had difficulties from time to time.)
If you're interested in using rvm, google "install rvm" to get the link for the installation instructions.
That said, you should make sure RubyMine is configured for your project to use the same Ruby you are using on the command line. That way, you will get consistent results in both environments.
Also. just FYI, you can email support#jetbrains.com for RubyMine questions.
I am trying to bundle install, but, for some strange reason, the pg gem is returning the following error on install:
$ gem install pg -v '0.18.4'
Building native extensions. This could take a while...
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.
/Users/username/.rvm/rubies/ruby-2.2.1/bin/ruby -r ./siteconf20151221-23315-1tkv3fd.rb 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... no
Can't find the 'libpq-fe.h header
*** 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/username/.rvm/rubies/ruby-2.2.1/bin/$(RUBY_BASE_NAME)
--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}/lib
extconf failed, exit code 1
Gem files will remain installed in /Users/username/.rvm/gems/ruby-2.2.1/gems/pg-0.18.4 for inspection.
Results logged to /Users/username/.rvm/gems/ruby-2.2.1/extensions/x86_64-darwin-15/2.2.0/pg-0.18.4/gem_make.out
Can anyone please help me install this gem and make my bundle finish successfully?
You should probably install the PostgreSQL development libraries.
If you're on Ubuntu this will help:
sudo apt-get install libpq-dev
On a Mac:
brew install postgresql
You need to configure pg correctly.
Run:
bundle config build.pg --with-pg-config=/Applications/Postgres.app/Contents/Versions/(YOUR POSTGRES VERSION)/bin/pg_config
Then try to run bundle:
bundle install
If the PostgreSQL client library is installed, then you need to tell gem where to look for the include files, which it does by asking pg_config. I use a little shell file to make it easier for gem to find that utility:
#!/bin/sh -x
PATH=/Library/PostgreSQL/9.4/bin:$PATH
gem install pg $#
You could also manually adjust your PATH to always include the PostgreSQL bin directory, which should fix the problem permanently.
If you upgrade your PostgreSQL that path will change, so you might need to reinstall pg and/or change your PATH setting.
Once pg is installed, further upgrades to the gem will be able to install without rerunning the script.
I tried to install pg Gem on Mac El Capitan, but I always get this error:
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb --with-pg-config=/Users/ricardolopes/Developer/homebrew/bin/pg_config
Using config values from /Users/ricardolopes/Developer/homebrew/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... no
checking for PQconnectdb() in -llibpq... no
checking for PQconnectdb() in -lms/libpq... no
Can't find the PostgreSQL client library (libpq)
*** 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
--with-pg-dir
--without-pg-dir
--with-pg-include
--without-pg-include=${pg-dir}/include
--with-pg-lib
--without-pg-lib=${pg-dir}/
--with-pqlib
--without-pqlib
--with-libpqlib
--without-libpqlib
--with-ms/libpqlib
--without-ms/libpqlib
Gem files will remain installed in /Users/ricardolopes/Code/site-noticias/vendor/bundle/ruby/2.0.0/gems/pg-0.18.3 for inspection.
Results logged to /Users/ricardolopes/Code/site-noticias/vendor/bundle/ruby/2.0.0/gems/pg-0.18.3/ext/gem_make.out
An error occurred while installing pg (0.18.3), and Bundler cannot continue.
Make sure that gem install pg -v '0.18.3' succeeds before bundling.
I also tried:
ARCHFLAGS="-arch x86_64" gem install pg
When I tried it I got:
Building native extensions. This could take a while...
Successfully installed pg-0.18.3
invalid options: -f fivefish
(invalid options are ignored)
Parsing documentation for pg-0.18.3
Done installing documentation for pg after 3 seconds
1 gem installed
But I run bundle install and get the same error posted in the beginning of this post.
I tried reinstall PostgresSQL from brew.
Try this:
brew update
brew install postgresql
sudo gem install pg -v 'VERSION'
This worked for me:
sudo gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/9.4/bin/pg_config
Remember to change 9.4 to your postgres version, if different from 9.4.
For a basic Rails app, you probably already have SQLite installed, but in your Gemfile, it probably has simply:
gem 'sqlite3'
Do you just need PostgreSQL for production? Make sure your Gemfile has it as follows:
group :production do
gem 'pg'
end
Also, make sure your Gemfile has SQLite just for development:
group :development do
gem 'sqlite3'
end
then try running bundle install.
I am getting pretty desperate, i have tried every answer on the subject but nothing seems to work.
the error log looks like this:
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby -r ./siteconf20150523-16458-46bzoo.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
sh: /Applications/Postgres.app/Contents/Versions/9.3/bin/pg_config: No such file or directory
sh: /Applications/Postgres.app/Contents/Versions/9.3/bin/pg_config: No such file or directory
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... no
checking for PQconnectdb() in -llibpq... no
checking for PQconnectdb() in -lms/libpq... no
Can't find the PostgreSQL client library (libpq)
*** 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
--with-pg-dir
--without-pg-dir
--with-pg-include
--without-pg-include=${pg-dir}/include
--with-pg-lib
--without-pg-lib=${pg-dir}/
--with-pqlib
--without-pqlib
--with-libpqlib
--without-libpqlib
--with-ms/libpqlib
--without-ms/libpqlib
extconf failed, exit code 1
Gem files will remain installed in /Users/kevinegstorf/.rvm/gems/ruby-2.0.0-p643/gems/pg-0.18.2 for inspection.
Results logged to /Users/kevinegstorf/.rvm/gems/ruby-2.0.0-p643/extensions/universal-darwin-14/2.0.0/pg-0.18.2/gem_make.out
An error occurred while installing pg (0.18.2), and Bundler cannot continue.
Make sure that `gem install pg -v '0.18.2'` succeeds before bundling.
Installing gem install pg -v '0.18.2' gives me back the same error
I hope someone can help me. tnx
If you already install Postgres.app in Mac,
you should copy /Applications/Postgres.app/Contents/Version/9.4/bin/pg_config to another place. For example /home/pg_config
then run
bundle config build.pg --with-pg-config=/home/pg_config
bundle install
You should find your pg_config file and add it to the build command:
bundle config build.pg --with-pg-config=/usr/local/bin/pg_config
Since your pg_config file is located at /usr/local/bin/pg_config Did you try the command(edited) above?
If that doesn't help maybe try:
env ARCHFLAGS="-arch x86_64" gem install pg
I'm suddenly running into this issue when running 'bundle install'. Everything seems to be installing correctly, but then I run into an issue with 'pg', as so many others seem to do. As the message says, I try running 'gem install pg - '0.12.2'' but it still fails.
I'm on Snow Leopard 10.6 and this is the error I'm getting:
Installing pg (0.12.2) with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/Users/thomaskim/.rvm/rubies/ruby-1.9.3-p327/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... no
Can't find the 'libpq-fe.h header
*** 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/thomaskim/.rvm/rubies/ruby-1.9.3-p327/bin/ruby
--with-pg
--without-pg
--with-pg-dir
--without-pg-dir
--with-pg-include
--without-pg-include=${pg-dir}/include
--with-pg-lib
--without-pg-lib=${pg-dir}/lib
--with-pg-config
--without-pg-config
--with-pg_config
--without-pg_config
Gem files will remain installed in /Users/thomaskim/.bundler/tmp/1336/gems/pg-0.12.2 for inspection.
Results logged to /Users/thomaskim/.bundler/tmp/1336/gems/pg-0.12.2/ext/gem_make.out
An error occurred while installing pg (0.12.2), and Bundler cannot continue.
Make sure that `gem install pg -v '0.12.2'` succeeds before bundling.
First you need to make sure you have command line tools (package for Xcode) installed. Since you're on old version of OSX - you will have to research how to do that.
Than, using homebrew install postgress
brew install postgres
After that, everything should bundle with no issues.
It appears that you do not have postgres installed properly. I got a similar error when I was trying to install a pg module with npm. It disappeared after installing postgres properly.
Here's a link to download: http://www.postgresql.org/download/macosx/
If you run rails on your machine only in dev mode and use sql lite for that, you need don't need to install the production bundles.
So if your gemfile looke like that:
group :production do
gem 'pg'
end
Try installing the bundles with the following command:
gem install --without production