sprockets-rails: Error: Asset 'application.css' was not declared to be precompiled in production
I’m getting the error:
ActionView::Template::Error (Asset 'application.css' was not declared to be precompiled in production.
Declare links to your assets in 'app/assets/config/manifest.js'.
//= link application.css
and restart your server):
But I have my application.scss
(NOT .css) in app/assets/stylesheets
and my app/assets/config/manifest.js
says:
//= link_tree ../images
//= link_directory ../javascripts .js
//= link_directory ../stylesheets .scss
I’m using:
- sprockets 4.0.0
- sprockets-rails 3.2.1
- rails 6.0.2.1
Temporary solution: Downgrade the gem as follows:
gem 'sprockets-rails', '2.3.3'
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 26
- Comments: 16
Commits related to this issue
- Downgrade sprockets-rails Version 3 is causing the issue described here https://github.com/rails/sprockets-rails/issues/458 so downgrade to 2.3.3 for now. — committed to airslie/renalware-core by woodpigeon 4 years ago
- Downgrade sprockets-rails Version 3 is causing the issue described here https://github.com/rails/sprockets-rails/issues/458 so downgrade to 2.3.3 for now. — committed to airslie/renalware-core by woodpigeon 4 years ago
- Downgrade sprockets-rails Version 3 is causing the issue described here https://github.com/rails/sprockets-rails/issues/458 so downgrade to 2.3.3 for now. — committed to airslie/renalware-core by woodpigeon 4 years ago
- Downgrade sprockets-rails Version 3 is causing the issue described here https://github.com/rails/sprockets-rails/issues/458 so downgrade to 2.3.3 for now. — committed to airslie/renalware-core by woodpigeon 4 years ago
- Downgrade sprockets-rails Version 3 is causing the issue described here https://github.com/rails/sprockets-rails/issues/458 so downgrade to 2.3.3 for now. — committed to airslie/renalware-core by woodpigeon 4 years ago
- Use link not link_directory in assets manifest Linking the whole directory was causing the following error: ``` ActionView::Template::Error (Asset 'application.css' was not declared to be precompile... — committed to RyanofWoods/rails-react-swedish-birds by RyanofWoods 2 years ago
- Use link not link_directory in assets manifest Linking the whole directory was causing the following error: ``` ActionView::Template::Error (Asset 'application.css' was not declared to be precompile... — committed to RyanofWoods/rails-react-swedish-birds by RyanofWoods 2 years ago
- Bundle update Manifest.js dev fix: https://github.com/rails/sprockets-rails/issues/458 — committed to alphagov/govwifi-admin by A1Robson a year ago
- Update manifest.js to fix sprockets error The error is this: Error: Asset 'application.css' was not declared to be precompiled in production Not sure what the root cause is. In https://github.co... — committed to simonbaird/tiddlyhost by simonbaird a year ago
- fixed: Asset `app.css` was not declared to be precompiled in production. https://github.com/rails/sprockets-rails/issues/458 — committed to tdtc-hrb/veic_web-r2 by tdtc-hrb 8 months ago
rake tmp:clear
helped me.Doing what the error told me worked. My
app/assets/config/manifest.js
now looks like this:I too have
application.scss
and notapplication.css
. I have the same versions, except rails is 6.0.2.2Same problem, but with application.scss.erb.
Workaroud it with
I’ve also just had this same problem with the same versions, and the same temporary solution worked for me.
I’ve had this issue come up occasionally and worked around it by adding an empty newline to
/app/assets/config/manifest.js
loading a page, and then reverting the change.This helped me, thanks
Same problem for me. Sprockets updated it’s documentation to explain why this is happening and how to fix it. Essentially, you’ll need to add subdirectories in your
app/assets/stylesheets
. This solution is the only one that’s worked for me so far.Any solution to this? - it is in my manifest.js but also seeing the same:
I’m using and this happens intermittently:
Getting this error too. It’s weird, it’s intermittent and doesn’t happen all the time.
And already included that file in
manifest.js
file.Any ideas why it would be intermittent?
I’m using:
rake tmp:clear didn’t work for me downgrading to gem ‘sprockets-rails’, ‘2.3.3’ with bundle install worked for me
Worked. This should be added to the original post as the solution since so many people have 👍’d it.
The recommendation to downgrade
sprockets-rails
should be avoided. A local problem that can be easily solved by flushing yourRails.root/tmp
directory should not require making a commit and then unduly influencing every other environment, dev machine, CI system, etc.I ran into this issue because I had a
//= require
in my application.js that didn’t exist.Removing it fixed the error for me.