How It Works Features Pricing Blog Error Guides
Log In Start Free Trial
Rails · Ruby

Fix Sprockets::FileNotFound: couldn't find file 'application.css' with type 'text/css' in Rails

This error occurs when the Rails asset pipeline cannot locate a referenced asset file. It usually means the file was deleted, renamed, or the manifest is misconfigured. Check your app/assets/stylesheets directory for the file and verify your application.css manifest directives point to existing files.

Reading the Stack Trace

Sprockets::FileNotFound (couldn't find file 'application.css' with type 'text/css'): sprockets (4.2.1) lib/sprockets/resolve.rb:28:in `resolve' sprockets (4.2.1) lib/sprockets/environment.rb:24:in `find_asset' sprockets-rails (3.4.2) lib/sprockets/rails/helper.rb:375:in `resolve_asset_path' actionview (7.1.3) lib/action_view/helpers/asset_tag_helper.rb:298:in `stylesheet_link_tag' app/views/layouts/application.html.erb:8:in `_app_views_layouts_application_html_erb__render'

Here's what each line means:

Common Causes

1. Missing application.css manifest

The app/assets/stylesheets/application.css file was deleted or never created.

<!-- app/views/layouts/application.html.erb -->
<%= stylesheet_link_tag 'application', media: 'all' %>
<!-- But app/assets/stylesheets/application.css does not exist -->

2. Incorrect manifest directives

The manifest file references stylesheets that do not exist in the asset paths.

/*
 *= require nonexistent_framework
 *= require_tree .
 *= require_self
 */

3. Asset not in load path

The asset exists but is in a directory not included in the Rails asset load paths.

# File is at vendor/custom/styles.css but vendor/custom is not in asset paths
# config/initializers/assets.rb does not include the path
Rails.application.config.assets.paths << Rails.root.join('vendor', 'custom')  # missing

The Fix

Create or restore the application.css manifest file with correct directives. The require_tree directive includes all stylesheets in the directory and require_self includes styles defined in the manifest itself.

Before (broken)
<!-- app/views/layouts/application.html.erb -->
<%= stylesheet_link_tag 'application', media: 'all' %>
<!-- application.css is missing or has bad directives -->
After (fixed)
/* app/assets/stylesheets/application.css */
/*
 *= require_tree .
 *= require_self
 */

Testing the Fix

require 'rails_helper'

RSpec.describe 'Application layout', type: :request do
  it 'renders the layout with stylesheets' do
    get root_path
    expect(response).to have_http_status(:ok)
    expect(response.body).to include('stylesheet')
  end

  it 'does not raise asset errors' do
    expect { get root_path }.not_to raise_error
  end
end

Run your tests:

bundle exec rspec spec/requests/layout_spec.rb

Pushing Through CI/CD

git checkout -b fix/rails-asset-pipeline,git add app/assets/stylesheets/application.css,git commit -m "fix: restore application.css manifest for asset pipeline",git push origin fix/rails-asset-pipeline

Your CI config should look something like this:

name: CI
on:
  pull_request:
    branches: [main]
jobs:
  test:
    runs-on: ubuntu-latest
    services:
      postgres:
        image: postgres:16
        env:
          POSTGRES_PASSWORD: postgres
        ports: ['5432:5432']
    steps:
      - uses: actions/checkout@v4
      - uses: ruby/setup-ruby@v1
        with:
          ruby-version: '3.3'
          bundler-cache: true
      - run: bin/rails db:setup
      - run: bin/rails assets:precompile
      - run: bundle exec rspec

The Full Manual Process: 18 Steps

Here's every step you just went through to fix this one bug:

  1. Notice the error alert or see it in your monitoring tool
  2. Open the error dashboard and read the stack trace
  3. Identify the file and line number from the stack trace
  4. Open your IDE and navigate to the file
  5. Read the surrounding code to understand context
  6. Reproduce the error locally
  7. Identify the root cause
  8. Write the fix
  9. Run the test suite locally
  10. Fix any failing tests
  11. Write new tests covering the edge case
  12. Run the full test suite again
  13. Create a new git branch
  14. Commit and push your changes
  15. Open a pull request
  16. Wait for code review
  17. Merge and deploy to production
  18. Monitor production to confirm the error is resolved

Total time: 30-60 minutes. For one bug.

Or Let bugstack Fix It in Under 2 minutes

Every step above? bugstack does it automatically.

Step 1: Install the SDK

gem install bugstack

Step 2: Initialize

require 'bugstack'

Bugstack.init(api_key: ENV['BUGSTACK_API_KEY'])

Step 3: There is no step 3.

bugstack handles everything from here:

  1. Captures the stack trace and request context
  2. Pulls the relevant source files from your GitHub repo
  3. Analyzes the error and understands the code context
  4. Generates a minimal, verified fix
  5. Runs your existing test suite
  6. Pushes through your CI/CD pipeline
  7. Deploys to production (or opens a PR for review)

Time from error to fix deployed: Under 2 minutes.

Human involvement: zero.

Try bugstack Free →

No credit card. 5-minute setup. Cancel anytime.

Deploying the Fix (Manual Path)

  1. Verify the application.css manifest file exists and has valid directives.
  2. Run bin/rails assets:precompile to confirm assets compile successfully.
  3. Run the test suite.
  4. Open a pull request with the fix.
  5. Merge and verify assets load correctly in staging.

Frequently Asked Questions

BugStack runs the fix through your existing test suite, generates additional edge-case tests, and validates that no other components are affected before marking it safe to deploy.

BugStack never pushes directly to production. Every fix goes through a pull request with full CI checks, so your team can review it before merging.

New Rails 7+ apps default to Propshaft or importmaps. Sprockets is still supported but Propshaft is simpler. If starting fresh, consider Propshaft with cssbundling-rails.

Add the path to config.assets.paths in config/initializers/assets.rb. For example: Rails.application.config.assets.paths << Rails.root.join('vendor', 'custom').