# Installing ruby-postgres gem

**URL:** <https://www.ruby-forum.com/t/installing-ruby-postgres-gem/159697>\
**Category:** Rails\
**Created:** [February 7, 2009, 7:32am UTC](https://www.ruby-forum.com/t/installing-ruby-postgres-gem/159697 "2009-02-07T07:32:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![captaffy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/f04885/32.png) [@captaffy](https://www.ruby-forum.com/u/captaffy)\
**Post date:** [February 7, 2009, 7:32am UTC](https://www.ruby-forum.com/t/installing-ruby-postgres-gem/159697/1 "2009-02-07T07:32:26Z")

</div>

I’m starting to look at postgres because I’m going to need it for its  
GIS extensions. But I run in into a problem when trying to install the  
ruby-postgres gem. I get this error

Building native extensions. This could take a while…  
ERROR: Error installing ruby-postgres:  
ERROR: Failed to build gem native extension.  
blah  
blah  
blah etc  
postgres.c:31: error: conflicting types for â€˜pg\_encoding\_to\_charâ€™  
/usr/include/postgresql/libpq-fe.h:518: error: previous declaration of  
â€˜pg\_encoding\_to\_charâ€™ was here  
postgres.c: In function â€˜pgconn\_s\_escape\_byteaâ€™:  
postgres.c:370: warning: pointer targets in passing argument 1 of  
â€˜PQescapeByteaâ€™ differ in signedness  
postgres.c: In function â€˜pgconn\_s\_unescape\_byteaâ€™:  
postgres.c:401: warning: pointer targets in passing argument 1 of  
â€˜PQunescapeByteaâ€™ differ in signedness  
make: \*\*\* [postgres.o] Error 1

Presumably some people have installed Postgresql and got it to work with  
Ruby. Does anyone have any experience solving this problem?

Thanks

John S.

---

<div class="post-metadata">

**Author:** ![captaffy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/f04885/32.png) [@captaffy](https://www.ruby-forum.com/u/captaffy)\
**Post date:** [April 8, 2009, 6:40pm UTC](https://www.ruby-forum.com/t/installing-ruby-postgres-gem/159697/2 "2009-04-08T18:40:21Z")

</div>

change /usr/include/libpq-fe.h (extern const char  
\*pg\_encoding\_to\_char(int encoding); to extern char  
\*pg\_encoding\_to\_char(int encoding)😉 # remove const

---

<div class="post-metadata">

**Author:** ![captaffy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/f04885/32.png) [@captaffy](https://www.ruby-forum.com/u/captaffy)\
**Post date:** [April 9, 2009, 7:56am UTC](https://www.ruby-forum.com/t/installing-ruby-postgres-gem/159697/3 "2009-04-09T07:56:50Z")

</div>

Jorge Queiruga wrote:

> change /usr/include/libpq-fe.h (extern const char  
> \*pg\_encoding\_to\_char(int encoding); to extern char  
> \*pg\_encoding\_to\_char(int encoding)😉 # remove const

Thanks for that I’ve already switched to using the newer ruby-pg gem and  
that seems OK.

Ta

John S.
