2

Making lots of progress in a rails 3.1 to 3.2.6 upgrade for a Heroku app.

I use asset_sync and precompile assets onto S3. I use the asset_sync.rb initialiser to config my S3 connection details.

Getting an error when I attempt to run

RAILS_ENV=production bundle exec rake assets:precompile

AssetSync: using /Users/bob/work/myapp/config/initializers/asset_sync.rb
rake aborted!
could not connect to server: Permission denied
    Is the server running locally and accepting
    connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"?

Tasks: TOP => environment
(See full trace by running task with --trace)
rake aborted!
Command failed with status (1): [/Users/bob/.rvm/rubies/ruby-1.9.3-p...]

That's very strange. I checked that it is listening as per Postgres permission denied on MAC OS X that question and related comments.

Community
  • 1
  • 1
Dave
  • 11,392
  • 5
  • 31
  • 42
  • Rake commands such as rake db:reset work fine. Typing psql into the command line gives the exact same error unless I specify psql -h localhost postgres postgres - what is it about trying to do? asset_sync.rb contains my Amazon S3 credentials - why is it falling on this error? Full stack trace means its active-record 3.2.6: – Dave Jun 17 '12 at 11:37
  • rake aborted! could not connect to server: Permission denied Is the server running locally and accepting connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"? /Users/bob/.rvm/gems/ruby-1.9.3-p0@rails32/gems/activerecord-3.2.6/lib/active_record/connection_adapters/postgresql_adapter.rb:1206:in `initialize' /Users/bob/.rvm/gems/ruby-1.9.3-p0@rails32/gems/activerecord-3.2.6/lib/active_record/connection_adapters/postgresql_adapter.rb:1206:in `new' ... – Dave Jun 17 '12 at 11:38
  • If I take host: localhost out of database.yml I get the same error on commands like rails console. Once that is in though those commands work fine, but the assets precompile still fails with the above. – Dave Jun 17 '12 at 11:47

1 Answers1

1

this isn't an error with asset_sync, but the asset precompile process itself (specifically on heroku) try config.assets.initialize_on_precompile = false in your production or application.rb

What this will do is make sure your application code does not get initialized unnecessarily, which at precompile time, your heroku database my not be available.

Also it's not an issue with just Rails 3.2.6 but 3.2.x I believe.

David Rice
  • 314
  • 2
  • 3