Reputation: 91
I'm gonna start by saying I hate heroku with a passion right now.
Okay, onto it. I'm pushing an app to heroku, and getting the "precompiling assets failed" error. I've tried about 100 things to fix it, and nothing works. I've tried setting
config.assets.initialize_on_precompile = false
In my application.rb file, doesn't work. I've tried precompiling locally, comiting and pushing, as well as hiding locally precompiled assets. I've tried pushing in different environments as well.
Here is my error log, where things start to happen:
> Preparing app for Rails asset pipeline
Running: rake assets:precompile
rake aborted!
SyntaxError: (erb):82: syntax error, unexpected ':', expecting ')'
(erb):85: unterminated string meets end of file
/tmp/build_1843337b33065f83ff572061af54f827/vendor/bundle/ruby/2.1.0/gems/mongoid-4.0.0/lib/mongoid/config/environment.rb:40:in `load_yaml'
/tmp/build_1843337b33065f83ff572061af54f827/vendor/bundle/ruby/2.1.0/gems/mongoid-4.0.0/lib/mongoid/config.rb:83:in `load!'
/tmp/build_1843337b33065f83ff572061af54f827/vendor/bundle/ruby/2.1.0/gems/mongoid-4.0.0/lib/mongoid.rb:99:in `load!'
/tmp/build_1843337b33065f83ff572061af54f827/vendor/bundle/ruby/2.1.0/gems/mongoid-4.0.0/lib/mongoid/railtie.rb:75:in `block in <class:Railtie>'
/tmp/build_1843337b33065f83ff572061af54f827/vendor/bundle/ruby/2.1.0/gems/railties-4.1.6/lib/rails/initializable.rb:30:in `instance_exec'
/tmp/build_1843337b33065f83ff572061af54f827/vendor/bundle/ruby/2.1.0/gems/railties-4.1.6/lib/rails/initializable.rb:30:in `run'
/tmp/build_1843337b33065f83ff572061af54f827/vendor/bundle/ruby/2.1.0/gems/railties-4.1.6/lib/rails/initializable.rb:55:in `block in run_initializers'
/tmp/build_1843337b33065f83ff572061af54f827/vendor/bundle/ruby/2.1.0/gems/railties-4.1.6/lib/rails/initializable.rb:54:in `run_initializers'
/tmp/build_1843337b33065f83ff572061af54f827/vendor/bundle/ruby/2.1.0/gems/railties-4.1.6/lib/rails/application.rb:300:in `initialize!'
/tmp/build_1843337b33065f83ff572061af54f827/config/environment.rb:5:in `<top (required)>'
/tmp/build_1843337b33065f83ff572061af54f827/vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.6/lib/active_support/dependencies.rb:247:in `require'
/tmp/build_1843337b33065f83ff572061af54f827/vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.6/lib/active_support/dependencies.rb:247:in `block in require'
/tmp/build_1843337b33065f83ff572061af54f827/vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.6/lib/active_support/dependencies.rb:232:in `load_dependency'
/tmp/build_1843337b33065f83ff572061af54f827/vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.6/lib/active_support/dependencies.rb:247:in `require'
/tmp/build_1843337b33065f83ff572061af54f827/vendor/bundle/ruby/2.1.0/gems/railties-4.1.6/lib/rails/application.rb:276:in `require_environment!'
/tmp/build_1843337b33065f83ff572061af54f827/vendor/bundle/ruby/2.1.0/gems/railties-4.1.6/lib/rails/application.rb:389:in `block in run_tasks_blocks'
/tmp/build_1843337b33065f83ff572061af54f827/vendor/bundle/ruby/2.1.0/gems/sprockets-rails-2.2.4/lib/sprockets/rails/task.rb:64:in `block (2 levels) in define'
Tasks: TOP => environment
I see the "syntax error" near the top, but I have no idea which file to look in. Can anyone help me out?
Here's the end of my mongoid.yml file, from lines 78 to 90
78 staging:
79 sessions:
80 default:
81 database: <dbname>
82 hosts:
83 - <host>:<port>
84 username: <username>
85 password: <password>
86 options:
87 production:
88 sessions:
89 default:
90 uri: <%= ENV['MONGOHQ_URL'] %>
Upvotes: 0
Views: 572
Reputation: 13663
The first few lines of the stacktrace point you to the problem:
Running: rake assets:precompile
rake aborted!
SyntaxError: (erb):82: syntax error, unexpected ':', expecting ')'
(erb):85: unterminated string meets end of file
/tmp/build_1843337b33065f83ff572061af54f827/vendor/bundle/ruby/2.1.0/gems/mongoid-4.0.0/lib/mongoid/config/environment.rb:40:in `load_yaml'
The error occured when Mongoid tried to load its YAML config, mongoid.yml
.
This has nothing to do with Heroku. The line of mongoid.yml
mentioned in the stacktrace points to the staging
part, and you should be able to reproduce the error locally by running:
bundle exec rake assets:precompile RAILS_ENV=staging
BTW, are you still running Rails 3? Because according to Heroku:
In Rails 4.x this option [
initialize_on_precompile
] has been removed and is no longer needed.
My guess is you need to quote strings containing colons. It should be:
78 staging:
79 sessions:
80 default:
81 database: <dbname>
82 hosts:
83 - '<host>:<port>'
84 username: <username>
85 password: <password>
86 options:
87 production:
88 sessions:
89 default:
90 uri: <%= ENV['MONGOHQ_URL'] %>
not - <host>:<port>
(notice the single quotes above).
Upvotes: 2