Postgresql adapter not working

Hello everyone. I’m starting with Rails going through the obvious
“Getting Started with Rails” guide:

http://guides.rubyonrails.org/getting_started.html

Everything goes smoothly until the rake db:create command, which
returns this strange error message referring to a gem that apparently
doesn’t exist:

Please install the postgresql adapter: gem install activerecord- postgresql-adapter (pg is not part of the bundle. Add it to Gemfile.)

I am trying to connect to a remote postgres server with the following
contents in database.yml:

common: &common
adapter: postgresql
host: the_server
database: my_db
encoding: unicode
pool: 5
timeout: 5000
username: me
password: mypass

development:
<<: *common

test:
<<: *common

production:
<<: *common

Which only adds the host line to what is shown in the tutorial.

After confirming that the pg gem is installed I tried two things:
first install the libdbd-pg-ruby package for Ubuntu, and then replaced
the pg gem for postgres-pr, as suggested here:

Neither of these actions changed matters, the error remains. What else
can I do to trace this problem?

Thank you,

Lus

Hello again,

Browsing a bit more I stumbled on a suggestion to install yet another
gem:
postgres. This gem doesn’t even install:

$ gem install postgres
Fetching: postgres-0.7.9.2008.01.28.gem (100%)
Building native extensions. This could take a while…
ERROR: Error installing postgres:
ERROR: Failed to build gem native extension.

    /home/desousa/.rvm/rubies/ruby-1.9.2-p290/bin/ruby extconf.rb

extconf.rb:4:in `’: uninitialized constant Object::PLATFORM
(NameError)

Gem files will remain installed in
/home/desousa/.rvm/gems/ruby-1.9.2-p290/gems/postgres-0.7.9.2008.01.28
for
inspection.
Results logged to
/home/desousa/.rvm/gems/ruby-1.9.2-p290/gems/postgres-0.7.9.2008.01.28/ext/gem_make.out

What’s the issue with this particular gem?

So far I tried 3 different gems for postgres adapter, each recommended
at
different places on the web. Is there an “official” Rails gem for
postgres?
Or an “official” adapter install guide?

Thank you,

Lus

2011/10/4 Lus de Sousa [email protected]

Hello again,

I managed to get rake db:create to work, it requires the creation of an
application with the -d postgresql argument. Nevertheless, it throws a
strange message saying that the database already exists. I will move
onwards
with the tutorial to see if it really works.

I think this issue should be made clear on the tutorial; some basic
guidelines on which adapter to use could also be helpful.

Thank you,

Lus

2011/10/5 Lus de Sousa [email protected]

2011/10/5 Lus de Sousa [email protected]

Hello again,

I managed to get rake db:create to work, it requires the creation of an
application with the -d postgresql argument. Nevertheless, it throws a
strange message saying that the database already exists. I will move onwards
with the tutorial to see if it really works.

I think this issue should be made clear on the tutorial; some basic
guidelines on which adapter to use could also be helpful.

I read you use Ubuntu (am I correct ?).

When googling for “install ruby on rails ubuntu”

  • the first entry points to a page on help.ubuntu.com that talks about
    8.04
    and 9.04
  • the second entry points to a very short description help.ubuntu.com
  • the third page points to a broken page on http://wiki.rubyonrails.org/
  • and then we get into private blogs, which may be OK, but are less
    authorative

I would volunteer to make a proper write-up for Ruby and Rails on Ubuntu
10.04
and/or 11.10 with rvm, ruby 1.9.(2|3), postgresql, etc.

Particularly I would also make clear which extra -dev Debian packages
are
needed
for native compilation when starting from a vanilla Ubuntu (32 bit x86)
client machine
install.

That could be similar in style to what I did on my blog for Jaunty
(9.04) a
few years ago
http://vandenabeele.com/Rails-on-Ubuntu-Jaunty

My goal is to put a correct how-to in the place that is most easily
found by
newcomers
that are working on Ubuntu.

Maybe most efficient would be to update the number 1 hit that is the
Ubuntu
help Wiki.

Would this be useful, or is this problem solved and did I just not find
the
correct
pointers by googling? (in that case, I could update the wiki to point
there
or copy
the correct description on the Ubuntu help Wiki).

Thanks for your feedback,

Peter

On Oct 6, 2011, at 9:48 AM, Peter V. wrote:

That could be similar in style to what I did on my blog for Jaunty
Would this be useful, or is this problem solved and did I just not
find the correct
pointers by googling? (in that case, I could update the wiki to
point there or copy
the correct description on the Ubuntu help Wiki).

Thanks for your feedback,

Peter

tl;dr https://gist.github.com/1261571

At Gaslight Software, we are helping a group at a local high school
develop a simple web application and have exactly this same situation.

We went with Ubuntu 10.04 LTS, Ruby 1.9.2, Rails 3.1, and PostgreSQL,
but the steps should be the same.

Configuring Ubuntu 10.04 for Rails Development

http://blog.gaslightsoftware.com/post/11027905735/configuring-ubuntu-10-04-for-rails-development

Our time is limited with them so we’re only sure that everything gets
installed, but we’ve gotten six ubuntu workstations configured and
next week should actually spin up a demo rails app.

-Rob

Rob B.
[email protected] http://AgileConsultingLLC.com/
[email protected] http://GaslightSoftware.com/

Oh and, don’t forget to install the ‘pg’ gem with the command-line
“gem install ‘pg’”.

You should install PgAdmin 3 to manage your database with an user
interface. It’s very helpfull to see if you database is already
created or some other few issues…

I managed to get rake db:create to work, it requires the creation of an
application with the -d postgresql argument. Nevertheless, it throws a
strange message saying that the database already exists. I will move onwards
with the tutorial to see if it really works.

Yes: to create a postgresql based application, you need to use the “-d
postgresql” argument, if you forgot it, just open the Gemfile and add
the instruction “gem ‘pg’” instead of “gem ‘sqlite3’” and update the
bundle with the command-line “bundle update”.

I’m using postgresql 9.1 on ubuntu 11.04 with rails 3.1, and
everything’s good for me.

HTH,
Maz.

That seems useful, Thank you Bob.

Lus

Hi Peter,

That not exactly the same issue, I’d say an authoritative install
guide for Ubuntu is definitely needed, especially since a direct
install from the repositories won’t work.

I used this guide which got Rails and Ruby to work on Ubuntu 10.10 64-
bit:

http://ryanbigg.com/2010/12/ubuntu-ruby-rvm-rails-and-you/

Though it installed the pg adapter instead of the postgres-pr gem.

Lus

On Oct 6, 6:16pm, Romain Maz BILLOIR [email protected] wrote:

Yes: to create a postgresql based application, you need to use the “-d
postgresql” argument, if you forgot it,

One can only forget things one has learned in the past. I’ll stick to
postgres-pr for now, it is recommended in several places on the web
and so far seems to work without trouble.

Lus

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs