I want to build a Rails 3 app for Heroku. They use Postgres as their db so I installed postgres 9.0 via MacPorts. Now I need a postgres gem and the consensus is that for performance reasons you want the pg gem. However I'm completely baffled by the errors I'm getting when I try and install pg via gem install under rvm.
I have been very explicit by specifying where all the postgres directories are to be found but still am unable to complete the install:
$ env ARCHFLAGS='-arch x86_64' gem install pg -- \
--with-pg-config=/opt/local/var/db/postgresql90/defaultdb/postgresql.conf \
--with-pg-include=/opt/local/include/postgresql90/ \
--with-pg-lib=/opt/local/lib/postgresql90/
Using config values from /opt/local/var/db/postgresql90/defaultdb/postgresql.conf
*** 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=/Users/guy/.rvm/ruby-1.9.2-p136/bin/ruby
--with-pg
--without-pg
--with-pg-dir
--without-pg-dir
--with-pg-include=${pg-dir}/include
--with-pg-lib=${pg-dir}/lib
--with-pg-config
extconf.rb:24:in ``': Exec format error - /opt/local/var/db/postgresql90/defaultdb/postgresql.conf --includedir (Errno::ENOEXEC)
from extconf.rb:24:in `<main>'
Anyone got any ideas? I'm baffled. Guy
I think your problem is right here:
--with-pg-config=/opt/local/var/db/postgresql90/defaultdb/postgresql.conf
The --with-pg-config
switch probably wants to know where the pg_config
script is rather than were postgresql.conf
is. You should have a pg_config
script somewhere under /opt/local/bin
(probably), it should produce a big pile of stuff like this:
BINDIR = /Users/mu/Developer/Cellar/postgresql/9.0.1/bin
DOCDIR = /Users/mu/Developer/Cellar/postgresql/9.0.1/share/doc
HTMLDIR = /Users/mu/Developer/Cellar/postgresql/9.0.1/share/doc
INCLUDEDIR = /Users/mu/Developer/Cellar/postgresql/9.0.1/include
PKGINCLUDEDIR = /Users/mu/Developer/Cellar/postgresql/9.0.1/include
INCLUDEDIR-SERVER = /Users/mu/Developer/Cellar/postgresql/9.0.1/include/server
LIBDIR = /Users/mu/Developer/Cellar/postgresql/9.0.1/lib
PKGLIBDIR = /Users/mu/Developer/Cellar/postgresql/9.0.1/lib
...
when you run it. The pg_config
script tells you (or whoever is asking) where the various header files and libraries are and which compiler flags are needed.
The "Exec format error" error message is the give away. That sounds like you're trying to execute something that the OS doesn't know how to execute and I wouldn't expect OSX to know how to execute some arbitrary configuration file.
Simplest fix I use: add /opt/local/lib/postgresql90/bin/ to your $PATH.
Say you use bash shell, then in ~/.bashrc
PATH=/opt/local/lib/postgresql90/bin:$PATH
Now a simple line in Gemfile:
gem 'pg'
will just work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With