# Installing the Postgres gem on Ubuntu

**URL:** <https://www.ruby-forum.com/t/installing-the-postgres-gem-on-ubuntu/60640>\
**Category:** Rails\
**Created:** [May 16, 2006, 1:46pm UTC](https://www.ruby-forum.com/t/installing-the-postgres-gem-on-ubuntu/60640 "2006-05-16T13:46:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![revlob](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/c77e96/32.png) [@revlob](https://www.ruby-forum.com/u/revlob)\
**Post date:** [May 16, 2006, 1:46pm UTC](https://www.ruby-forum.com/t/installing-the-postgres-gem-on-ubuntu/60640/1 "2006-05-16T13:46:21Z")

</div>

Hi,

I’m having difficulty installing the “postgres” gem. postgres-pr  
installed fine, but whenever I run:

sudo gem install postgres

I get:

ERROR: While executing gem … (RuntimeError)  
ERROR: Failed to build gem native extension.  
Gem files will remain installed in  
/usr/lib/ruby/gems/1.8/gems/postgres-0.7.1 for inspection.

I’ve had a bit of a poke around, and gathered that the problem is gem  
not knowing where to find the postgres libraries and includes. However,  
I’ve tried various combinations of  
–with-pgsql-dir/–with-pgsql-lib-dir/–with-pgsql-include-dir/etc, with  
no luck so far. Has anyone encountered a smiliar problem and managed to  
resolve it?

I’m running ruby 1.8.4, rails 1.1.2, gem 0.8.11, and postgres 8.0. I  
also have the postgresql-dev package installed.

Thanks.

---

<div class="post-metadata">

**Author:** ![revlob](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/c77e96/32.png) [@revlob](https://www.ruby-forum.com/u/revlob)\
**Post date:** [May 16, 2006, 2:02pm UTC](https://www.ruby-forum.com/t/installing-the-postgres-gem-on-ubuntu/60640/2 "2006-05-16T14:02:11Z")

</div>

On Tue, May 16, 2006 at 01:46:21PM +0200, David E. wrote:  
} Hi,  
}  
} I’m having difficulty installing the “postgres” gem. postgres-pr  
} installed fine, but whenever I run:

The postgres-pr does not have any native extension. The -pr stands for  
Pure  
Ruby. Your issue is with building the native extensions.

} sudo gem install postgres  
}  
} I get:  
}  
} ERROR: While executing gem … (RuntimeError)  
} ERROR: Failed to build gem native extension.  
} Gem files will remain installed in  
} /usr/lib/ruby/gems/1.8/gems/postgres-0.7.1 for inspection.  
}  
} I’ve had a bit of a poke around, and gathered that the problem is gem  
} not knowing where to find the postgres libraries and includes.  
However,  
} I’ve tried various combinations of  
} --with-pgsql-dir/–with-pgsql-lib-dir/–with-pgsql-include-dir/etc,  
with  
} no luck so far. Has anyone encountered a smiliar problem and managed  
to  
} resolve it?  
}  
} I’m running ruby 1.8.4, rails 1.1.2, gem 0.8.11, and postgres 8.0. I  
} also have the postgresql-dev package installed.

I’m working from Debian knowledge rather than Ubuntu knowledge, but  
things  
should be similar. First, have you tried installing libpgsql-ruby (or  
libpgsql-ruby1.8)? Under Debian, it is the package for the Ruby driver  
for  
PostgreSQL in a system package rather than a gem. I usually prefer to  
install system packages rather than gems when possible, especially those  
with native extensions (e.g. librmagick-ruby).

If those packages do not exist in Ubuntu, be sure that ruby-dev (or  
ruby1.8-dev) is installed, as well as libpq-dev, then try the gem  
install  
again. Again, I am working from Debian knowledge so it might not apply.  
Good luck. If this doesn’t help I recommend consulting an Ubuntu mailing  
list.

} Thanks.  
–Greg

---

<div class="post-metadata">

**Author:** ![revlob](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/c77e96/32.png) [@revlob](https://www.ruby-forum.com/u/revlob)\
**Post date:** [May 16, 2006, 2:20pm UTC](https://www.ruby-forum.com/t/installing-the-postgres-gem-on-ubuntu/60640/3 "2006-05-16T14:20:39Z")

</div>

Although I cannot remember the name of the package, there is a  
Postgres/Ruby lib for connecting these two technologies.

I have used Postgres on Ubuntu before without any problems.

HTH

Nicholas

---

<div class="post-metadata">

**Author:** ![revlob](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/c77e96/32.png) [@revlob](https://www.ruby-forum.com/u/revlob)\
**Post date:** [May 16, 2006, 7:43pm UTC](https://www.ruby-forum.com/t/installing-the-postgres-gem-on-ubuntu/60640/4 "2006-05-16T19:43:31Z")

</div>

Nicholas T. wrote:

> Although I cannot remember the name of the package, there is a  
> Postgres/Ruby lib for connecting these two technologies.
> 
> I have used Postgres on Ubuntu before without any problems.
> 
> HTH
> 
> Nicholas

This may help, [http://mgreenly.metaspot.net/?p=38](http://mgreenly.metaspot.net/?p=38) or maybe not.
