Ruby on Rails and Postgres - Installing postgresql gem

Hey there,

I’m trying to get started with RoR with Postgresql.

I’ve been trying to find some information on it, but there’s a lot of
really
OLD info on that subject!

What should I do to get my application working with Postgresql?

I get an error while trying to install the gem.

After reading i thought many info about alot of different gems.

Which one is the right one?

[]'s
Rodrigo D.

Rodrigo D. wrote:

Hey there,

I’m trying to get started with RoR with Postgresql.

I’ve been trying to find some information on it, but there’s a lot of
really
OLD info on that subject!

What should I do to get my application working with Postgresql?

I get an error while trying to install the gem.

Which gem (there are several)? What error?

After reading i thought many info about alot of different gems.

Which one is the right one?

I believe I’m using the postgres gem, though I’ll verify that when I’m
not posting from my iPhone. :slight_smile: Others have reported success with
postgres-pr (pure ruby) or pg.

Search the list archives for more, or perhaps there’s information at
Robby on Rails, since he uses Postgres.

[]'s
Rodrigo D.

Best,
–Â
Marnen Laibow-Koser
http://www.marnen.org
[email protected]

I tried postgres, ruby-pg etc… all give me this error.

Building native extensions. This could take a while…
ERROR: Error installing postgres:
ERROR: Failed to build gem native extension.

/usr/bin/ruby1.9.1 extconf.rb
extconf.rb:4:in `’: uninitialized constant PLATFORM (NameError)

Gem files will remain installed in
/var/lib/gems/1.9.1/gems/postgres-0.7.9.2008.01.28 for inspection.
Results logged to
/var/lib/gems/1.9.1/gems/postgres-0.7.9.2008.01.28/ext/gem_make.out

What do I need to have installed so they build properly?

[]'s
Rodrigo D.

On Sun, Jan 10, 2010 at 11:09 PM, Marnen Laibow-Koser

It seems that I’m lacking some dev libraries that Im not aware of.

Anyone knows?

[]'s
Rodrigo D.

On Jan 11, 5:55Â am, Rodrigo D. [email protected] wrote:

After reading i thought many info about alot of different gems.

Which one is the right one?

I’m up and running with the postgres gem with postgresql 8.3.5. If i
recall correctly it was a very quick and painless setup.

On Jan 11, 12:13Â pm, Rodrigo D. [email protected] wrote:

It seems that I’m lacking some dev libraries that Im not aware of.

Anyone knows?

Perhaps the development packages for postgresql?

Hey there,

Thanks for all the answers so far, it seems that there are 3 gems
currently
working, pg, postgres, ruby-pg.

But I can’t get it to build, does anyone knows which libs I need to have
installed? or where to check that?

I currently have postgres-8.4-dev

[]s
Rodrigo D.

Rodrigo D. wrote:

Hey there,

Thanks for all the answers so far, it seems that there are 3 gems
currently
working, pg, postgres, ruby-pg.

But I can’t get it to build, does anyone knows which libs I need to have
installed? or where to check that?

I currently have postgres-8.4-dev

I think you may need libpq. Check the gem docs.

[]s
Rodrigo D.

Best,
–Â
Marnen Laibow-Koser
http://www.marnen.org
[email protected]

This is generally confusing but here’s what I think you should do:

  1. Remove postgres and ruby-pg gems if they are installed; the
    correct, current one is pg which should be at version 0.8.0 (assuming
    you’re on linux, this all might change on windows).
  2. The library packages you’re missing is most likely libpq-dev (on
    ubuntu sudo apt-get install libpq-dev, not sure about other distros);
    in addition i’d try adding in build-essential if you don’t have it, as
    well as ruby1.8-dev.
  3. After that try doing a gem install pg; if that fails the error
    message tells you where the error log is for the build, posting that
    would help identify what is missing.

Good luck

\Peter

On Jan 10, 3:55Â pm, Rodrigo D. [email protected] wrote:

After reading i thought many info about alot of different gems.

Which one is the right one?

Hi Rodrigo

I’m using PostgreSQL 8.3.x and the pg gem.

Peace,
Phillip

Hey Rodrigo and All.

I’m on OS X and it’s not easy to get going out of the box - IIRC i
usually
have an issue with a postgres gem when I use ports.
I’m looking into it now.

What platform are you working on Rodrigo?

Hi, Rodrigo:

What’s your error? What environment are you running under?

We have it working fine with a PostgreSQL dbase.I believe the gem is:
pg(0.8.0).

Thanks,

Gary.

Curtis S. wrote:

Hey Rodrigo and All.

I’m on OS X and it’s not easy to get going out of the box

Actually it’s quite easy. Install PostgreSQL, install headers (perhaps
through Fink), install gem. Done.

  • IIRC i
    usually
    have an issue with a postgres gem when I use ports.

So don’t use ports!

I’m looking into it now.

What platform are you working on Rodrigo?

Best,
–Â
Marnen Laibow-Koser
http://www.marnen.org
[email protected]

I’m glad it was easy for you.

  • IIRC i

usually
have an issue with a postgres gem when I use ports.

So don’t use ports!

Thanks for your suggestion - I’m not in the habit of throwing something
out
when with some patience
I can learn something new.

For anyone else who’s had trouble with macports here is a walk through.

http://robotarmyma.de/post/329089358/postgresql-gem-pg-macmin-x86-64bit-macports

Big thanks to the note
http://www.icoretech.org/2009/08/how-to-install-pg-postgresql-gem-on-snow-leopard-64-bit/

Curtis S. wrote:

I’m glad it was easy for you.

  • IIRC i

usually
have an issue with a postgres gem when I use ports.

So don’t use ports!

Thanks for your suggestion - I’m not in the habit of throwing something
out
when with some patience
I can learn something new.

Agreed, but there’s also no sense in using the wrong tool for the job.

For anyone else who’s had trouble with macports here is a walk through.

http://robotarmyma.de/post/329089358/postgresql-gem-pg-macmin-x86-64bit-macports

Big thanks to the note
http://www.icoretech.org/2009/08/how-to-install-pg-postgresql-gem-on-snow-leopard-64-bit/

Best,
–Â
Marnen Laibow-Koser
http://www.marnen.org
[email protected]

On Mon, Jan 11, 2010 at 2:28 PM, Marnen Laibow-Koser
[email protected]wrote:

Thanks for your suggestion - I’m not in the habit of throwing something
out
when with some patience
I can learn something new.

Agreed, but there’s also no sense in using the wrong tool for the job.

Well be both can agree on that. I know from a long history of using
software that packages like fink or macports often have bugs and
occasionally we encounter them. After all, we programmers are human and
make
mistakes.

Hey guys, thanks for all the help on this.

k lets divide to conquer.

My Environment:

Ubuntu 9.10
Ruby1.9.1
Postgres 8.4

I have build-essential, libpq-dev and all that already installed.

The error was preventing me from installing the postgres or ruby-pg
gems.

Now that you mentioned, I had already uninstalled everything and I tried
installing the pg gem.

Well, odly enough it worked. But I still get an error while trying to
install postgres or ruby-pg, but pg will do for me.

Thx guys.

[]'s
Rodrigo D.

On Mon, Jan 11, 2010 at 4:40 PM, Curtis S. <