Yuyo
Yuyo

Reputation: 655

Precompiling assets doesn't seem to be working

I'm having a strange problem that I have never encountered when deploying my rails apps to production.

I run:

bundle exec rake assets:precompile

This is the output:

/home/ubuntu/.rvm/rubies/ruby-2.0.0-p0/bin/ruby /home/ubuntu/.rvm/gems/ruby-2.0.0-p0/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets
/home/ubuntu/.rvm/rubies/ruby-2.0.0-p0/bin/ruby /home/ubuntu/.rvm/gems/ruby-2.0.0-p0/bin/rake assets:precompile:nondigest RAILS_ENV=production RAILS_GROUPS=assets

This is my app/assets/javascripts/application.js:

//= require jquery
//= require jquery_ujs
//= require jquery.ui.all
//= require twitter/bootstrap
//= require_tree .

And this is my app/assets/stylesheets/application.css:

/*
 *= require_self
 *= require jquery.ui.all
 *= require_tree . 
*/

After I precompile, this is my public/assets/application-946a5a61f067fe19fe65ffd12f8c4a20.js

//= require jquery
//= require jquery_ujs
//= require jquery.ui.all
//= require twitter/bootstrap
//= require_tree .

So it's exactly the same as the original file.

And public/assets/application-df7525e917401704ef453cb56bf16697.css is an empty file.

This is my Gemfile:

source 'http://rubygems.org'

gem 'rails', '3.1.1'

# Bundle edge Rails instead:
# gem 'rails',     :git => 'git://github.com/rails/rails.git'

gem 'pg'
gem 'settingslogic'
gem 'jquery-rails'
gem 'jquery-ui-rails'
gem 'json'
gem 'will_paginate', '~>3.0.pre2'
gem 'friendly_id', '~> 4.0.0.beta14'
gem 'rails3-jquery-autocomplete'
gem 'omniauth'
gem 'omniauth-twitter'
gem 'omniauth-facebook'
gem 'paperclip', '~> 3.0'
gem 'public_activity'
gem 'rails-timeago'
gem 'therubyracer', :require => 'v8'
gem 'less-rails'
gem 'twitter-bootstrap-rails', :git => 'git://github.com/seyhunak/twitter-bootstrap-rails.git'

# Gems used only for assets and not required
# in production environments by default.
group :assets do
  gem 'sass-rails'
  gem 'coffee-rails'
  gem 'uglifier', '>= 1.0.3'
end

# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'

# Use unicorn as the web server
# gem 'unicorn'

# Deploy with Capistrano
# gem 'capistrano'

# To use debugger
# gem 'ruby-debug19', :require => 'ruby-debug'

group :test do
  # Pretty printed test output
  gem 'turn', :require => false
end

And config/environments/production.rb:

Yupp::Application.configure do
  # Settings specified here will take precedence over those in config/application.rb

  # Code is not reloaded between requests
  config.cache_classes = true

  # Full error reports are disabled and caching is turned on
  config.consider_all_requests_local       = false
  config.action_controller.perform_caching = true

  # Disable Rails's static asset server (Apache or nginx will already do this)
  config.serve_static_assets = false

  # Compress JavaScripts and CSS
  config.assets.compress = true

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

  # Generate digests for assets URLs
  config.assets.digest = true

  #config.assets.initialize_on_precompile = false

#...
end

Any direction will be greatly appreciated.

Upvotes: 1

Views: 2956

Answers (2)

Steve x slapps.fr
Steve x slapps.fr

Reputation: 1244

What solved the problem for me :

  • set the last rails version in Gemfile (3.2.14 for now)

  • bundle update

  • bundle install

  • restart the app touch tmp/restart.txt

Upvotes: 3

raven
raven

Reputation: 188

I spent 2 hours on this then I found https://github.com/sstephenson/sprockets/issues/352

I tried downgrade ruby to 1.9.3 and do precompile then add compiled files to repo.. This isn't what I want but it works..

Update: what rails version are you using ? I was using 3.2.2 which has problem like this. 3.2.13 works fine(with ruby 2.0).

Upvotes: 2

Related Questions