title: Capistrano generating empty application.css stylesheet when deploying
body: <p>I'm attempting to deploy my Rails app using Capistrano, but the resulting application.css stylesheet is empty. This happens for both my staging and production environments. The below relate to my staging one.</p>
  
  <p>This is using Rails 3.1.1, Ruby 2.0.0p0 and Capistrano 2.14.1</p>
  
  <p>I'll attempt to provide as much detail as possible (although sorry if it is too much detail).</p>
  
  <h2>Logs</h2>
  
  <p>When the deploy is run, the following is added to `staging.log':</p>
  
  <pre><code>Compiled application.js  (0ms)  (pid 15434)
  Compiled application.css  (0ms)  (pid 15434)
  Compiled application.js  (1ms)  (pid 15428)
  Compiled application.css  (0ms)  (pid 15428)
  </code></pre>
  
  <p>I'm not sure if the double entries might be a clue?</p>
  
  <p>The following is part of the output when I run <code>cap staging deploy</code>:</p>
  
  <pre><code>    command finished in 730ms
      triggering after callbacks for `deploy:update_code'
    * 2013-04-28 14:04:10 executing `deploy:assets:precompile'
      triggering before callbacks for `deploy:assets:precompile'
    * 2013-04-28 14:04:10 executing `deploy:assets:update_asset_mtimes'
    * executing "[ -e /home/somedomain.co.uk/staging/mkn/shared/assets/manifest.yml ] &amp;&amp; cat /home/somedomain.co.uk/staging/mkn/shared/assets/manifest.yml || echo"
      servers: ["homer.somedomain.co.uk"]
      [homer.somedomain.co.uk] executing command
      command finished in 614ms
   ** Updating mtimes for ~20 assets...
      servers: ["homer.somedomain.co.uk"]
   ** sftp upload #&lt;StringIO:0x007f945d8d6a28&gt; -&gt; /home/somedomain.co.uk/staging/mkn//TOUCH_ASSETS
      [homer.somedomain.co.uk] /home/somedomain.co.uk/staging/mkn//TOUCH_ASSETS
      [homer.somedomain.co.uk] done
    * sftp upload complete
    * executing "cat /home/somedomain.co.uk/staging/mkn//TOUCH_ASSETS | while read asset; do touch -cm -- \"$asset\"; done &amp;&amp; rm -f -- /home/somedomain.co.uk/staging/mkn//TOUCH_ASSETS"
      servers: ["homer.somedomain.co.uk"]
      [homer.somedomain.co.uk] executing command
      command finished in 812ms
    * executing "ls -x /home/somedomain.co.uk/staging/mkn/releases"
      servers: ["homer.somedomain.co.uk"]
      [homer.somedomain.co.uk] executing command
      command finished in 438ms
    * executing "cd -- /home/somedomain.co.uk/staging/mkn/releases/20130428130343 &amp;&amp; bundle exec rake RAILS_ENV=staging RAILS_GROUPS=assets assets:precompile &amp;&amp; cp -- /home/somedomain.co.uk/staging/mkn/shared/assets/manifest.yml /home/somedomain.co.uk/staging/mkn/releases/20130428130343/assets_manifest.yml"
      servers: ["homer.somedomain.co.uk"]
      [homer.somedomain.co.uk] executing command
   ** [out :: homer.somedomain.co.uk] /home/greggannicott/.rvm/gems/ruby-2.0.0-p0/gems/bundler-1.3.5/lib/bundler/runtime.rb:216: warning: Insecure world writable dir /home/somedomain.co.uk/staging/mkn/shared in PATH, mode 040777
   ** [out :: homer.somedomain.co.uk] /home/greggannicott/.rvm/rubies/ruby-2.0.0-p0/bin/ruby /home/somedomain.co.uk/staging/mkn/shared/bundle/ruby/2.0.0/bin/rake assets:precompile:nondigest RAILS_ENV=staging RAILS_GROUPS=assets
   ** [out :: homer.somedomain.co.uk] /home/greggannicott/.rvm/gems/ruby-2.0.0-p0/gems/bundler-1.3.5/lib/bundler/runtime.rb:216: warning: Insecure world writable dir /home/somedomain.co.uk/staging/mkn/shared in PATH, mode 040777
      command finished in 13990ms
    * 2013-04-28 14:04:26 executing `deploy:create_symlink'
    * executing "rm -f /home/somedomain.co.uk/staging/mkn/current &amp;&amp; ln -s /home/somedomain.co.uk/staging/mkn/releases/20130428130343 /home/somedomain.co.uk/staging/mkn/current"
      servers: ["homer.somedomain.co.uk"]
      [homer.somedomain.co.uk] executing command
      command finished in 581ms
   ** transaction: commit
    * 2013-04-28 14:04:26 executing `deploy:restart'
    * executing "touch /home/somedomain.co.uk/staging/mkn/current/tmp/restart.txt"
      servers: ["homer.somedomain.co.uk"]
      [homer.somedomain.co.uk] executing command
      command finished in 427ms
  </code></pre>
  
  <h2>Configuration Files</h2>
  
  <p>My <code>Capfile</code>:</p>
  
  <pre><code>load 'deploy'
  # Uncomment if you are using Rails' asset pipeline
  load 'deploy/assets'
  Dir['vendor/gems/*/recipes/*.rb','vendor/plugins/*/recipes/*.rb'].each { |plugin| load(plugin) }
  load 'config/deploy' # remove this line to skip loading any of the default tasks
  </code></pre>
  
  <p>My <code>config/application.rb</code>:</p>
  
  <pre><code>require File.expand_path('../boot', __FILE__)
  
  require 'rails/all'
  
  if defined?(Bundler)
    # If you precompile assets before deploying to production, use this line
    #Bundler.require(*Rails.groups(:assets =&gt; %w(development test)))
    # If you want your assets lazily compiled in production, use this line
    # Bundler.require(:default, :assets, Rails.env)
  end
  
  module Nuggets
    class Application &lt; Rails::Application
      # Settings in config/environments/* take precedence over those specified here.
      # Application configuration should go into files in config/initializers
      # -- all .rb files in that directory are automatically loaded.
  
      # Custom directories with classes and modules you want to be autoloadable.
      # config.autoload_paths += %W(#{config.root}/extras)
  
      # Only load the plugins named here, in the order given (default is alphabetical).
      # :all can be used as a placeholder for all plugins not explicitly named.
      # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
  
      # Activate observers that should always be running.
      # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
  
      # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
      # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
      # config.time_zone = 'Central Time (US &amp; Canada)'
  
      # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
      # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
      # config.i18n.default_locale = :de
  
      # Configure the default encoding used in templates for Ruby 1.9.
      config.encoding = "utf-8"
  
      # Configure sensitive parameters which will be filtered from the log file.
      config.filter_parameters += [:password]
  
      # Enable the asset pipeline
      config.assets.enabled = true
  
      # Version of your assets, change this if you want to expire all your assets
      config.assets.version = '1.2'
  
      config.generators do |g|
        g.test_framework :rspec,
          :fixtures =&gt; true,
          :view_specs =&gt; false,
          :helper_specs =&gt; false,
          :routing_specs =&gt; false,
          :controller_specs =&gt; true,
          :request_specs =&gt; true
        g.fixture_replacement :factory_girl, :dir =&gt; "spec/factories"
      end
    end
  end
  </code></pre>
  
  <p>My <code>config/environments/staging.rb</code>:</p>
  
  <pre><code>Nuggets::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
  
    # Defaults to Rails.root.join("public/assets")
    # config.assets.manifest = YOUR_PATH
  
    # Specifies the header that your server uses for sending files
    # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
    # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
  
    # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
    # config.force_ssl = true
  
    # See everything in the log (default is :info)
    config.log_level = :debug
  
    # Use a different logger for distributed setups
    # config.logger = SyslogLogger.new
  
    # Use a different cache store in production
    # config.cache_store = :mem_cache_store
  
    # Enable serving of images, stylesheets, and JavaScripts from an asset server
    # config.action_controller.asset_host = "http://assets.example.com"
  
    # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
    # config.assets.precompile += %w( search.js )
  
    # Disable delivery errors, bad email addresses will be ignored
    # config.action_mailer.raise_delivery_errors = false
  
    # Enable threaded mode
    # config.threadsafe!
  
    # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
    # the I18n.default_locale when a translation can not be found)
    config.i18n.fallbacks = true
  
    # Send deprecation notices to registered listeners
    config.active_support.deprecation = :notify
  
    # Show full error reports in the browser
    config.consider_all_requests_local       = true
  
  end
  </code></pre>
  
  <p>My <code>config/deploy.rb</code>:</p>
  
  <pre><code>require "rvm/capistrano"
  require 'bundler/capistrano'
  # Based on: http://guides.beanstalkapp.com/deployments/deploy-with-capistrano.html
  set :application, "nuggets"
  set :normalize_asset_timestamps, false
  
  set :scm, :git
  set :repository, "ssh://greggannicott@homer.somedomain.co.uk/home/git/nuggets.git"
  set :scm_passphrase, "*******"
  ssh_options[:forward_agent] = true
  
  set :user, "greggannicott"
  
  set :stages, %w{staging production}
  set :default_stage, "staging"
  require 'capistrano/ext/multistage'
  
  # The following needs to be added to avoid a failure (http://discuss.joyent.com/viewtopic.php?id=27326)
  default_run_options[:pty] = true
  
  namespace :deploy do
    desc "Tell Passenger to restart the app."
    task :restart do
      run "touch #{current_path}/tmp/restart.txt"
    end
  end
  
  set :bundle_flags,    ""
  </code></pre>
  
  <p>My <code>Gemfile</code>:</p>
  
  <pre><code>source 'http://rubygems.org'
  
  gem 'rails', '3.1.1'
  gem 'therubyracer', :platforms =&gt; :ruby # I believe this is required to run on Ubuntu due to a lack of a Javascript runtime env..
  gem 'rdiscount'
  gem 'bcrypt-ruby'
  gem 'will_paginate'
  gem 'faker'
  gem 'capistrano'
  gem 'rvm-capistrano'
  gem 'sqlite3'
  
  # Bundle edge Rails instead:
  # gem 'rails',     :git =&gt; 'git://github.com/rails/rails.git'
  
  
  # Gems used only for assets and not required
  # in production environments by default.
  group :assets do
    gem 'sass-rails',   '~&gt; 3.1.4'
    gem 'coffee-rails', '~&gt; 3.1.1'
    gem 'uglifier', '&gt;= 1.0.3'
  end
  
  gem 'jquery-rails'
  
  group :development do
    gem 'better_errors'
    gem 'binding_of_caller'
    gem 'meta_request'
    gem 'rspec-rails'
    gem 'guard-rspec'
    gem 'guard-spork'
    gem 'spork'
  end
  
  # To use ActiveModel has_secure_password
  # gem 'bcrypt-ruby', '~&gt; 3.0.0'
  
  # Use unicorn as the web server
  # gem 'unicorn'
  
  # Deploy with Capistrano
  # gem 'capistrano'
  
  # To use debugger
  # gem 'ruby-debug19', :require =&gt; 'ruby-debug'
  
  group :test do
    # Pretty printed test output
    gem 'turn', :require =&gt; false
    gem 'rspec-rails'
    gem 'factory_girl_rails'
    gem 'capybara'
    gem 'guard-rspec'
    gem 'rb-fsevent', :require =&gt; false
    gem 'growl'
  end
  </code></pre>
  
  <p>My <code>app/assets/stylesheets</code> directory listing:</p>
  
  <pre><code>-rw-rw-r--  1 greggannicott  staff    350 27 Jan 13:28 application.css
  -rw-rw-r--  1 greggannicott  staff  13622 27 Apr 23:35 global.css.scss
  -rw-rw-r--  1 greggannicott  staff  33211 27 Jan 13:28 jquery-ui-1.8.17.custom.css
  -rw-rw-r--  1 greggannicott  staff   2208 27 Jan 13:28 media-queries.css
  -rw-rw-r--  1 greggannicott  staff    178 27 Jan 13:28 nuggets.css.scss
  -rw-rw-r--  1 greggannicott  staff    176 27 Jan 13:28 pages.css.scss
  -rw-rw-r--  1 greggannicott  staff    179 27 Jan 13:28 sessions.css.scss
  -rw-rw-r--  1 greggannicott  staff    179 27 Jan 13:28 settings.css.scss
  -rw-rw-r--  1 greggannicott  staff    175 27 Jan 13:28 tags.css.scss
  -rw-rw-r--  1 greggannicott  staff    176 27 Jan 13:28 users.css.scss
  </code></pre>
  
  <p>Finally, my <code>app/assets/stylesheets/application.css</code>:</p>
  
  <pre><code>/*
   * This is a manifest file that'll automatically include all the stylesheets available in this directory
   * and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
   * the top of the compiled file, but it's generally better to create a new file per style scope.
   *= require_self
   *= require_tree .
  */
  </code></pre>