Hello everyone I am trying to install postgre on my macOS: Yosemite 10.10.2
First, I am doing this because I am trying to deploy my app on Heroku that doesn't support sqlite so I made the following:
group :development, :test do
gem 'sqlite3'
gem 'sqlite3-ruby', :require => 'sqlite3'
end
group :production do
gem 'pg'
end
So when I deploy it on heroku it's working fine.
But now I cannot run the 'bundle install' anymore cause it says I used the command:
sudo gem install pg --
--with-pg-config=/Applications/Postgres.app/Contents/Versions/9.4/bin/pg_config
--with-pg-include='/Applications/Postgres.app/Contents/Versions/9.3/include/'
-–with-pg-lib=/usr/lib
(I had tried each one of them separately before also)
Here is what I get:
sudo gem install pg --
--with-pg-config=/Applications/Postgres.app/Contents/Versions/9.4/bin/pg_config
--with-pg-include='/Applications/Postgres.app/Contents/Versions/9.3/include/'
–with-pg-lib=/usr/lib
Building native extensions with: '--with-pg-config=/Applications/Postgres.app/Contents/Versions/9.4/bin/pg_config --with-pg-include=/Applications/Postgres.app/Contents/Versions/9.3/include/ –with-pg-lib=/usr/lib'
This could take a while...
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby -r ./siteconf20150208-28855-hgneo3.rb extconf.rb --with-pg-config=/Applications/Postgres.app/Contents/Versions/9.4/bin/pg_config --with-pg-include=/Applications/Postgres.app/Contents/Versions/9.3/include/ –with-pg-lib=/usr/lib
Using config values from /Applications/Postgres.app/Contents/Versions/9.4/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.
extconf failed, exit code 1
Gem files will remain installed in /Library/Ruby/Gems/2.0.0/gems/pg-0.18.1 for inspection.
Results logged to /Library/Ruby/Gems/2.0.0/extensions/universal-darwin-14/2.0.0/pg-0.18.1/gem_make.out
I don't understand why he cannot get the PQconnectdb() ? Am I missing something here ?
Thanks in advance =)
Although you basically don't use the "production" environment on your local computer, you still need to install postgres on your computer to make everything work properly. According to your log, it seems you didn't install postgres correctly.
I recommend using homebrew to install it:
brew install postgres
You should not get this error when installing the pg
gem after installing postgres via homebrew.
If you use another approach to install it, you may need to add some parameters while installing the pg
gem. Here are some references: