Topic: postgresql 7.4 error: 'No such file or directory - /tmp/.s.PGSQL.5432'

I've just install ruby on rails 2.0.2 and postgresql 7.4 on my system (eeepc).

I have had this working in the past but now it doesn't work.  When I type 'rake db:migrate' I get the following error:

/home/user/winesite> rake --trace db:migrate
(in /home/user/winesite)
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:migrate
rake aborted!
No such file or directory - /tmp/.s.PGSQL.5432
/usr/lib/ruby/gems/1.8/gems/postgres-pr-0.4.0/lib/postgres-pr/connection.rb:140:in `initialize'
/usr/lib/ruby/gems/1.8/gems/postgres-pr-0.4.0/lib/postgres-pr/connection.rb:140:in `new'
/usr/lib/ruby/gems/1.8/gems/postgres-pr-0.4.0/lib/postgres-pr/connection.rb:140:in `establish_connection'
/usr/lib/ruby/gems/1.8/gems/postgres-pr-0.4.0/lib/postgres-pr/connection.rb:25:in `initialize'
/usr/lib/ruby/gems/1.8/gems/postgres-pr-0.4.0/lib/postgres-pr/postgres-compat.rb:23:in `new'
/usr/lib/ruby/gems/1.8/gems/postgres-pr-0.4.0/lib/postgres-pr/postgres-compat.rb:23:in `initialize'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/postgresql_adapter.rb:713:in `connect'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/postgresql_adapter.rb:713:in `connect'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/postgresql_adapter.rb:237:in `initialize'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/postgresql_adapter.rb:23:in `new'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/postgresql_adapter.rb:23:in `postgresql_connection'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/abstract/connection_specification.rb:291:in `send'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/abstract/connection_specification.rb:291:in `connection='
/usr/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/abstract/connection_specification.rb:259:in `retrieve_connection'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/abstract/connection_specification.rb:78:in `connection'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/migration.rb:294:in `migrate'
/usr/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/tasks/databases.rake:85
/usr/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:546:in `call'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:546:in `execute'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:541:in `each'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:541:in `execute'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:508:in `invoke_with_call_chain'
/usr/lib/ruby/1.8/thread.rb:135:in `synchronize'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:501:in `invoke_with_call_chain'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:494:in `invoke'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1931:in `invoke_task'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1909:in `top_level'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1909:in `each'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1909:in `top_level'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1948:in `standard_exception_handling'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1903:in `top_level'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1881:in `run'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1948:in `standard_exception_handling'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1878:in `run'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.1/bin/rake:31
/usr/bin/rake:19:in `load'
/usr/bin/rake:19

I've setup my database.yml file like this:
# Postgresql
#

development:
  adapter: postgresql
  database: winesite_development
  username: user
  password:
#  host: localhost
#  encoding: UTF-8

test:
  adapter: postgresql
  database: winesite_test
  username: user
  password:
#  host: localhost
#  encoding: UTF-8

production:
  adapter: postgresql
  database: winesite_production
  username: user
  password:
#  host: localhost
#  encoding: UTF-8


I've tested this project on another computer and it works fine, so I'm assuming it has something to do with the older version of postgresql (7.4 instead of 8.2) or the configuration of postgresql itself.

Is there certain things I should check under postgresql?

Last edited by map7 (2008-02-18 01:49:53)

Re: postgresql 7.4 error: 'No such file or directory - /tmp/.s.PGSQL.5432'

My guess is that your file lives under /var/run/postgresql/.s.PGSQL.5432 instead of under /tmp, can you verify?

Re: postgresql 7.4 error: 'No such file or directory - /tmp/.s.PGSQL.5432'

pullmonkey you were correct, I changed my postgres config and all came to life. Thanks.

Re: postgresql 7.4 error: 'No such file or directory - /tmp/.s.PGSQL.5432'

My friend and I traced through the postgres-pr source to track down his problem.  In gems/postgres-pr-0.4.0/lib/postgres-pr/connection.rb, we saw that it determines the path of the postgres lock file through the host variable in database.yml.  Simply add the line:

  host: /var/run/postgresql/

to you database.yml.  I've written down other postgresql notes at:

http://whatcodecraves.com/articles/2008 … postgresql

Because it's what code craves.