0

After running RAILS_ENV=production bundle exec rake assets:precompile and pushing to heroku, I get this error:

Running: rake assets:precompile
rake aborted!
could not connect to server: Connection refused
Is the server running on host "127.0.0.1" and accepting
TCP/IP connections on port 5432?

The complete log is here: http://dpaste.com/hold/1503531/

How can this happen when I have a public/assets/manifest-*.json file checked in? I'm using Rails 4.0.2.

In my production.rb I have:

config.assets.compile = false
nnyby
  • 4,748
  • 10
  • 49
  • 105
  • 1
    Possible duplicate of http://stackoverflow.com/questions/17733593/rails-4-heroku-doesnt-recognize-precompiled-manifest-fingerprint-json . Though I can't make heads or tails of his/her solution in the linked thread. – janfoeh Dec 12 '13 at 23:24
  • I saw that question, too. I couldn't understand the solution either. – nnyby Dec 13 '13 at 02:37
  • Do you get the error while pushing to Heroku, or afterwards? If it's while pushing, could you show us the full push log? – janfoeh Dec 13 '13 at 08:29
  • @janfoeh I get the error while pushing. Here's the complete log: http://dpaste.com/hold/1503531/ – nnyby Dec 13 '13 at 16:15

3 Answers3

3

I fixed the issue! I added an empty public/assets/manifest.yml file and pushed to heroku, and it no longer attempted the precompile while pushing.

Detected manifest.yml, assuming assets were compiled locally
nnyby
  • 4,748
  • 10
  • 49
  • 105
  • Good catch. The :assets group does not exist anymore in Rails 4: http://stackoverflow.com/questions/16406204/why-did-rails4-drop-support-for-assets-group-in-the-gemfile – janfoeh Dec 14 '13 at 14:52
  • @janfoeh that change didn't solve it actually. I've updated my answer - it seems like heroku is still relying on the presence of `public/assets/manifest.yml` even though it's deprecated in rails 4. – nnyby Dec 15 '13 at 22:16
1

gem 'capistrano-rails', '~> 1.1.3'

this issue is fixed in version 1.1.3

Xuanyu
  • 661
  • 5
  • 12
0

Make sure you set config.assets.initialize_on_precompile = false in config/application.rb to prevent asset compilation from initializing a full Rails instance. If that is left unset, the Rails instance will be instantiated and try to start like normal, trying to connect to your database.

config.assets.initialize_on_precompile = false

This is mentioned in the red alert box under Precompiling Assets and in bold just before it says, "Heroku requires this to be false.".

Ross Allen
  • 43,772
  • 14
  • 97
  • 95
  • `config.assets.initialize_on_precompile` is no longer around in Rails 4: http://stackoverflow.com/a/20008359/173630 https://github.com/rails/rails/blob/master/railties/lib/rails/application/configuration.rb – nnyby Dec 17 '13 at 00:28
  • 1
    The setting won't be removed until 4.1 according to the commit message: https://github.com/rails/rails/commit/2d5a6de4e227ee97ccbea691c69728b7e31bf678#diff-19128a84fe2ae7019ccdb86efc86f684 Is there an equivalent in Rails 4? – Ross Allen Dec 17 '13 at 00:45