Heroku ignores public/assets/manifest-*.json

2019-08-31 02:07发布

问题:

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

回答1:

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


回答2:

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

this issue is fixed in version 1.1.3



回答3:

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.".