RoR App: "The asset 'application.css' is not present in the asset pipeline" after moving to production server
Asked Answered
E

2

7

after moving my Ruby on Rails app to production server (AWS EC2 Amazon Linux 2018.03) pages don't render, because of error "The asset 'application.css' is not present in the asset pipeline" (precompiled files are presents in public/assets): production.log

However, when I refresh my application (sometimes more then once), this file is found in cache and page is rendering correctly. It seems like server doesn't wait for file precompilation or something like that. It happens not only on first page entry, but every change of view.

I followed tips from post: application.css not in asset pipeline, but it didn't help.

My stack:

  • ruby 2.6.3
  • rails 5.2.3
  • Unicorn 5.5.1
  • nginx 1.14.1

I will be really grateful for any hints.

Elver answered 25/6, 2019 at 11:59 Comment(0)
T
5

You can confirm your app/assets/stylesheets folder it should have application.css file and you will have to precompile assets in production environment before go/start server in production environment. You can precompile assets using

RAILS_ENV=production rails assets:precompile

If it still does not work then you can try the config.assets.compile option to true in production.rb so it will do live compilation. Although it should be false in production environment as it impact on performance.

config.assets.compile = true
Tann answered 25/6, 2019 at 13:2 Comment(4)
Unforunately, it didn't helpElver
I think the first command should have been rake and not rails i.e RAILS_ENV=production rake assets:precompileChuvash
@Elver Try restarting rails.Wildee
If it didn't help, why did you accept the answer? It's confusing other peopleSausauce
B
1

I had this problem on a GitHub Action workflow, and adding this line fixed it:

bundle exec rake assets:precompile

Example

        run: |
          bundle exec rails db:prepare
          bundle exec rake assets:precompile # <--- here
Belew answered 14/7, 2022 at 17:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.