Why does Rails fails to boot with "Expected to find a manifest file in `app/assets/config/manifest.js` (Sprockets::Railtie::ManifestNeededError)"?

They've changed things with the latest version of sprockets. This error comes up because you don't have a manifest.js created. You need to create one, and add in a few lines to make sure things are working. In the old version of sprockets, they made big assumptions about which assets sprockets is taking care of (i.e. bundling and concatenating). Not anymore. Now you have to tell sprockets explicitly, what files you want taken care of: and you do this in your manifest.js file.

Easy Steps To Solve the Problem:

  1. Create the manifest.js file

    $ mkdir -p app/assets/config

    $ touch app/assets/config/manifest.js (not the root rails directory)

  2. Then copy and paste the following into the manifest.js file you just created:

    //= link_tree ../images
    //= link_directory ../javascripts .js
    //= link_directory ../stylesheets .css
    
  3. If you have a precompile array in your app/config/ folder (see below for an example) e.g. app/config/production.rb then perhaps you should move them over to your manifest.js if they are not already accessed above.

    config.assets.precompile = ["admin.js", "admin.css"]

  4. Lastly, if you are using webpacker, you might want to decide what you want handled by the asset pipeline and what you want handled by webpacker. i.e. remove the link_directory to the javascripts file according to your own particular use cases.

Source: Thanks to Richard Schneeman's blog - see here for more information..


A new major version of sprockets was recently released which is not compatible with the previous version.

Either perform the steps needed to upgrade or pin to version 3.x in Gemfile

gem 'sprockets', '~>3.0'

Based on the answer here you may be able to solve this with:

mkdir -p app/assets/config && echo '{}' > app/assets/config/manifest.js

And if you need more details, the answer in this thread helpfully points to the Guide to upgrading from Sprockets 3.x to 4.x