# Can't install gem postgre for Ruby

**URL:** <https://www.ruby-forum.com/t/cant-install-gem-postgre-for-ruby/157792>\
**Category:** Rails\
**Created:** [January 15, 2009, 11:55am UTC](https://www.ruby-forum.com/t/cant-install-gem-postgre-for-ruby/157792 "2009-01-15T11:55:32Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![raimon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/59ef9b/32.png) [@raimon](https://www.ruby-forum.com/u/raimon)\
**Post date:** [January 15, 2009, 11:55am UTC](https://www.ruby-forum.com/t/cant-install-gem-postgre-for-ruby/157792/1 "2009-01-15T11:55:32Z")

</div>

Hello,

I have two computers and in one I can install the gem as expected, but  
in the other, I can’t.

The differences are that in the one that I can, I compiled&installed  
postgre myself, in the one that doesn’t work, the installation has been  
made with the the .dmg file from enterprisedb

Before I uninstall and install again, how I can specific the correct  
path to the pg\_config --libdir ?

Here is what I get:

sh-3.2# env ARCHFLAGS="-arch i386" gem install --remote postgres  
Building native extensions. This could take a while…  
ERROR: Error installing postgres:  
ERROR: Failed to build gem native extension.

/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby  
extconf.rb install --remote postgres  
extconf.rb:73: command not found: pg\_config --bindir  
extconf.rb:46: command not found: pg\_config --includedir  
extconf.rb:53: command not found: pg\_config --libdir  
checking for main() in -lpq… no  
\*\*\* 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-pgsql-dir  
–without-pgsql-dir  
–with-pgsql-include  
–without-pgsql-include=${pgsql-dir}/include  
–with-pgsql-lib  
–without-pgsql-lib=${pgsql-dir}/lib  
–with-pqlib  
–without-pqlib  
Could not find PostgreSQL build environment (libraries & headers):  
Makefile not created

The libraries are in /usr/local/postresql/ in both computers …

thanks,

r.

---

<div class="post-metadata">

**Author:** ![raimon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/59ef9b/32.png) [@raimon](https://www.ruby-forum.com/u/raimon)\
**Post date:** [January 15, 2009, 12:15pm UTC](https://www.ruby-forum.com/t/cant-install-gem-postgre-for-ruby/157792/2 "2009-01-15T12:15:17Z")

</div>

On 15 Jan, 11:55, Raimon Fs [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Hello,
> 
> I have two computers and in one I can install the gem as expected, but  
> in the other, I can’t.
> 
> The differences are that in the one that I can, I compiled&installed  
> postgre myself, in the one that doesn’t work, the installation has been  
> made with the the .dmg file from enterprisedb

I think the swiches you need to add are --with-pgsql-include-dir and –  
with-pgsql-lib-dir. If the .dmg does indeed include the required  
headers and libraries, that is.  
You could also just go with the postgres-pr (pr for “pure ruby”) gem  
if this isn’t a production server.

PS: It’s “pg”, “Postgres” or “PostgreSQL”, not “Postgre”.

Isak

---

<div class="post-metadata">

**Author:** ![raimon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/59ef9b/32.png) [@raimon](https://www.ruby-forum.com/u/raimon)\
**Post date:** [January 15, 2009, 12:26pm UTC](https://www.ruby-forum.com/t/cant-install-gem-postgre-for-ruby/157792/3 "2009-01-15T12:26:21Z")

</div>

Isak wrote:

> On 15 Jan, 11:55, Raimon Fs [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > Hello,
> > 
> > I have two computers and in one I can install the gem as expected, but  
> > in the other, I can’t.
> > 
> > The differences are that in the one that I can, I compiled&installed  
> > postgre myself, in the one that doesn’t work, the installation has been  
> > made with the the .dmg file from enterprisedb
> 
> I think the swiches you need to add are --with-pgsql-include-dir and –  
> with-pgsql-lib-dir. If the .dmg does indeed include the required  
> headers and libraries, that is.  
> You could also just go with the postgres-pr (pr for “pure ruby”) gem  
> if this isn’t a production server.
> 
> PS: It’s “pg”, “Postgres” or “PostgreSQL”, not “Postgre”.

thanks for the clarification. I don’t know how to add those switches  
without getting an error.

as this is not a production server, I’ve installed the postgres-pr gem  
without any problem.

I’m going to try to find more info about this pr gem.

r.

---

<div class="post-metadata">

**Author:** ![raimon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/59ef9b/32.png) [@raimon](https://www.ruby-forum.com/u/raimon)\
**Post date:** [January 15, 2009, 1:41pm UTC](https://www.ruby-forum.com/t/cant-install-gem-postgre-for-ruby/157792/4 "2009-01-15T13:41:19Z")

</div>

On 15 Jan 2009, at 11:26, Raimon Fs wrote:

> > > postgre myself, in the one that doesn’t work, the installation has
> > 
> > PS: It’s “pg”, “Postgres” or “PostgreSQL”, not “Postgre”.
> 
> thanks for the clarification. I don’t know how to add those switches  
> without getting an error.

gem install foo – --with\_something\_dir=…

Fred

---

<div class="post-metadata">

**Author:** ![raimon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/59ef9b/32.png) [@raimon](https://www.ruby-forum.com/u/raimon)\
**Post date:** [January 15, 2009, 1:50pm UTC](https://www.ruby-forum.com/t/cant-install-gem-postgre-for-ruby/157792/5 "2009-01-15T13:50:53Z")

</div>

Frederick C. wrote:

> On 15 Jan 2009, at 11:26, Raimon Fs wrote:
> 
> > > > postgre myself, in the one that doesn’t work, the installation has
> > > 
> > > PS: It’s “pg”, “Postgres” or “PostgreSQL”, not “Postgre”.
> > 
> > thanks for the clarification. I don’t know how to add those switches  
> > without getting an error.
> 
> gem install foo – --with\_something\_dir=…
> 
> Fred

thanks, I can’t install either but the – works ok.

let’s uninstall and install again compiling it …

thanks,

r.

---

<div class="post-metadata">

**Author:** ![raimon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/59ef9b/32.png) [@raimon](https://www.ruby-forum.com/u/raimon)\
**Post date:** [January 16, 2009, 11:37am UTC](https://www.ruby-forum.com/t/cant-install-gem-postgre-for-ruby/157792/6 "2009-01-16T11:37:07Z")

</div>

After uninstalling and installing again from source code, I’m having the  
same problem …

Wich postgres gem versuion it’s the most newer for Ruby ?

This is a new project, I don’t care for old compatibilities, I think the  
newest is the one I’m trying to install.

Do I have to specify some special options while compiling/installing  
postgresql from source ?

The only difference from one computer (works) to the other (doesn’t  
work) is the postgresql version:

8.3 works  
8.3.5 doesn’t work (can’t find the libraries …)

Any help would be much appreciated …

thanks,

r.

---

<div class="post-metadata">

**Author:** ![raimon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/59ef9b/32.png) [@raimon](https://www.ruby-forum.com/u/raimon)\
**Post date:** [January 16, 2009, 6:25pm UTC](https://www.ruby-forum.com/t/cant-install-gem-postgre-for-ruby/157792/7 "2009-01-16T18:25:17Z")

</div>

Fernando P. wrote:

> > Wich postgres gem versuion it’s the most newer for Ruby ?
> 
> Hi,
> 
> sudo gem install pg
> 
> That’s the newest.
> 
> –  
> On demand video training for distance learners: [http://www.digiprof.fr](http://www.digiprof.fr)

thanks!

I have had to add theARCHFLAGS but finally I could install it:

sh-3.2# sudo env ARCHFLAGS=“-arch i386” gem install pg

thanks!

r.

---

<div class="post-metadata">

**Author:** ![raimon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/59ef9b/32.png) [@raimon](https://www.ruby-forum.com/u/raimon)\
**Post date:** [January 16, 2009, 5:29pm UTC](https://www.ruby-forum.com/t/cant-install-gem-postgre-for-ruby/157792/8 "2009-01-16T17:29:13Z")

</div>

> Wich postgres gem versuion it’s the most newer for Ruby ?

Hi,

sudo gem install pg

That’s the newest.

–  
On demand video training for distance learners: [http://www.digiprof.fr](http://www.digiprof.fr)

---

<div class="post-metadata">

**Author:** ![raimon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/59ef9b/32.png) [@raimon](https://www.ruby-forum.com/u/raimon)\
**Post date:** [January 21, 2010, 11:18pm UTC](https://www.ruby-forum.com/t/cant-install-gem-postgre-for-ruby/157792/9 "2010-01-21T23:18:22Z")

</div>

Hi, I solved it by running “sudo apt-get install libpq-dev”, which  
installed the libraries for development needs.
