Skip to content

"Expected to find a manifest file" error with assets disabled #444

Closed
@delner

Description

@delner

With the release of Sprockets 4.0 and the requirement of a manifest.js file, we're seeing an error similar to #443 with sprockets-rails 3.2.1 where our test suite is producing this error:

/usr/local/bundle/gems/sprockets-rails-3.2.1/lib/sprockets/railtie.rb:105:in `block in <class:Railtie>': Expected to find a manifest file in `app/assets/config/manifest.js` (Sprockets::Railtie::ManifestNeededError)
But did not, please create this file and use it to link any assets that need
to be rendered by your app:

Example:
  //= link_tree ../images
  //= link_directory ../javascripts .js
  //= link_directory ../stylesheets .css
and restart your server

We load the standard require 'rails/all' in our test suite (which loads sprockets 4.0 by default), but we have no interest in using Sprockets or the asset pipeline within it.

If we disable Sprockets with config.assets.enabled = false in our application, we expect that we shouldn't need to have a manifest.js file. However, merely having require 'sprockets/railtie' anywhere in your application will force this check to occur unconditionally, regardless of if you've disabled the the application pipeline:

https://github.com/rails/sprockets-rails/blob/v3.2.1/lib/sprockets/railtie.rb#L103-L110

initializer :set_default_precompile do |app|
  if using_sprockets4?
    raise ManifestNeededError unless ::Rails.root.join("app/assets/config/manifest.js").exist?
    app.config.assets.precompile += %w( manifest.js )
  else
    app.config.assets.precompile += [LOOSE_APP_ASSETS, /(?:\/|\\|\A)application\.(css|js)$/]
  end
end

I would suggest changing this check to be based conditionally on whether assets are enabled or not, so users are not forced to completely remove sprocket-rails to disable it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions