Skip to content

Instantly share code, notes, and snippets.

@mingderwang
Created April 14, 2013 06:56
Show Gist options
  • Save mingderwang/5381735 to your computer and use it in GitHub Desktop.
Save mingderwang/5381735 to your computer and use it in GitHub Desktop.
Can't find the PostgreSQL client library (libpq) solution.
$sudo gem install activerecord-postgresql-adapter
Password:
Building native extensions. This could take a while...
ERROR: Error installing activerecord-postgresql-adapter:
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 /Library/Ruby/Gems/1.8/gems/pg-0.15.1 for inspection.
Results logged to /Library/Ruby/Gems/1.8/gems/pg-0.15.1/ext/gem_make.out
TRY THIS
$ brew install PostgreSQL
==> Installing postgresql dependency: readline
==> Downloading http://ftpmirror.gnu.org/readline/readline-6.2.tar.gz
######################################################################## 100.0%
==> Patching
patching file callback.c
patching file input.c
patching file patchlevel
patching file support/shobj-conf
patching file vi_mode.c
==> ./configure --prefix=/opt/boxen/homebrew/Cellar/readline/6.2.4 --mandir=/opt
==> make install
==> Caveats
This formula is keg-only: so it was not symlinked into /opt/boxen/homebrew.
OS X provides the BSD libedit library, which shadows libreadline.
In order to prevent conflicts when programs look for libreadline we are
defaulting this GNU Readline installation to keg-only.
Generally there are no consequences of this for you. If you build your
own software and it requires this formula, you'll need to add to your
build variables:
LDFLAGS: -L/opt/boxen/homebrew/opt/readline/lib
CPPFLAGS: -I/opt/boxen/homebrew/opt/readline/include
==> Summary
🍺 /opt/boxen/homebrew/Cellar/readline/6.2.4: 31 files, 1.6M, built in 33 seconds
==> Installing postgresql dependency: ossp-uuid
==> Downloading ftp://ftp.ossp.org/pkg/lib/uuid/uuid-1.6.2.tar.gz
curl: (7) couldn't connect to host
Trying a mirror...
==> Downloading http://gnome-build-stage-1.googlecode.com/files/uuid-1.6.2.tar.g
######################################################################## 100.0%
==> ./configure --prefix=/opt/boxen/homebrew/Cellar/ossp-uuid/1.6.2 --without-pe
==> make
==> make install
==> Caveats
This formula is keg-only: so it was not symlinked into /opt/boxen/homebrew.
OS X provides a uuid.h which conflicts with ossp-uuid's header.
Generally there are no consequences of this for you. If you build your
own software and it requires this formula, you'll need to add to your
build variables:
LDFLAGS: -L/opt/boxen/homebrew/opt/ossp-uuid/lib
CPPFLAGS: -I/opt/boxen/homebrew/opt/ossp-uuid/include
==> Summary
🍺 /opt/boxen/homebrew/Cellar/ossp-uuid/1.6.2: 15 files, 232K, built in 24 seconds
==> Installing postgresql
==> Downloading http://ftp.postgresql.org/pub/source/v9.2.4/postgresql-9.2.4.tar
######################################################################## 100.0%
==> Patching
patching file src/pl/plpython/Makefile
patching file contrib/uuid-ossp/uuid-ossp.c
==> ./configure --prefix=/opt/boxen/homebrew/Cellar/postgresql/9.2.4 --datadir=/
==> make install-world
==> Caveats
# Build Notes
If builds of PostgreSQL 9 are failing and you have version 8.x installed,
you may need to remove the previous version first. See:
https://github.com/mxcl/homebrew/issues/issue/2510
To build plpython against a specific Python, set PYTHON prior to brewing:
PYTHON=/usr/local/bin/python brew install postgresql
See:
http://www.postgresql.org/docs/9.2/static/install-procedure.html
# Create/Upgrade a Database
If this is your first install, create a database with:
initdb /opt/boxen/homebrew/var/postgres -E utf8
To migrate existing data from a previous major version (pre-9.2) of PostgreSQL, see:
http://www.postgresql.org/docs/9.2/static/upgrading.html
# Loading Extensions
By default, Homebrew builds all available Contrib extensions. To see a list of all
available extensions, from the psql command line, run:
SELECT * FROM pg_available_extensions;
To load any of the extension names, navigate to the desired database and run:
CREATE EXTENSION [extension name];
For instance, to load the tablefunc extension in the current database, run:
CREATE EXTENSION tablefunc;
For more information on the CREATE EXTENSION command, see:
http://www.postgresql.org/docs/9.2/static/sql-createextension.html
For more information on extensions, see:
http://www.postgresql.org/docs/9.2/static/contrib.html
# Other
Some machines may require provisioning of shared memory:
http://www.postgresql.org/docs/9.2/static/kernel-resources.html#SYSVIPC
To install postgresql (and ossp-uuid) in 32-bit mode:
brew install postgresql --32-bit
If you want to install the postgres gem, including ARCHFLAGS is recommended:
env ARCHFLAGS="-arch x86_64" gem install pg
To install gems without sudo, see the Homebrew wiki.
To have launchd start postgresql at login:
ln -sfv /opt/boxen/homebrew/opt/postgresql/*.plist ~/Library/LaunchAgents
Then to load postgresql now:
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
Or, if you don't want/need launchctl, you can just run:
pg_ctl -D /opt/boxen/homebrew/var/postgres -l /opt/boxen/homebrew/var/postgres/server.log start
==> Summary
🍺 /opt/boxen/homebrew/Cellar/postgresql/9.2.4: 2831 files, 39M, built in 4.3 minutes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment