Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ruby on Rails Rake assets:precompile error

I'm new in Rails development and this is my first deployment to Heroku. When I execute my application (after the deployment) there is an error:

2011-09-18T21:05:54+00:00 app[web.1]: Completed 500 Internal Server Error in 10ms
2011-09-18T21:05:54+00:00 app[web.1]:
2011-09-18T21:05:54+00:00 app[web.1]: ActionView::Template::Error (application.css isn't precompiled):

I googled this and found that I have to precompile my assets, but when trying to do this I found an other error:

$ bundle exec rake assets:precompile RAILS_ENV=production
rake aborted!
No such process - /usr/lib/ruby/gems/1.8/gems/pg-0.11.0/lib/pg_ext.so

(See full trace by running task with --trace)

I haven't found any solution for this issue. Is there anyone who faced this an know how to solve this problem?

like image 248
fabiogasparro Avatar asked Sep 18 '11 21:09

fabiogasparro


People also ask

What is Rails assets precompile?

The Rails asset pipeline provides an assets:precompile rake task to allow assets to be compiled and cached up front rather than compiled every time the app boots. There are two ways you can use the asset pipeline on Heroku. Compiling assets locally. Compiling assets during slug compilation.

How to enable asset pipeline in Rails?

The asset pipeline is implemented by the sprockets-rails gem, and is enabled by default. You can disable it while creating a new application by passing the --skip-asset-pipeline option. The sassc-rails gem is automatically used for CSS compression if included in the Gemfile and no config. assets.


Video Answer


3 Answers

I ran into this issue as well and I resolved it by doing the following:

Open up config/environments/production.rb and make sure the following option is set to true:

# Don't fallback to assets pipeline if a precompiled asset is missed
config.assets.compile = true

Then run:

rake assets:precompile --trace RAILS_ENV=production

Hope this helps!

~Kevin

like image 171
Kevin B Avatar answered Sep 26 '22 05:09

Kevin B


I got the problem too. But you can

rake assets:precompile RAILS_ENV=production

in local, and push to heroku with public/assets. It's resolved.

like image 30
user808749 Avatar answered Sep 24 '22 05:09

user808749


I would recommend to use the new Cedar stack. It precompiles assets for you on deploy and overall plays nicer with Rails 3.1, although you will need to configure your app a little bit to work: add some gems to your Gemfile and create a Procfile. But it is still an easier way to go.

like image 30
Simon Perepelitsa Avatar answered Sep 24 '22 05:09

Simon Perepelitsa