23

env

Rails 6.0.0
Ruby 2.6.0
Amazon Linux2

What

enter image description here

When I deploy my rails app this error happen

ActionView::Template::Error (Webpacker can't find application in /home/web/www/eloop-regular/public/packs/manifest.json. Possible causes:
1. You want to set webpacker.yml value of compile to true for your environment
   unless you are using the `webpack -w` or the webpack-dev-server.
2. webpack has not yet re-run to reflect updates.
3. You have misconfigured Webpacker's config/webpacker.yml file.
4. Your webpack configuration is not creating a manifest.

1. You want to set webpacker.yml value of compile to true for your environment unless you are using the webpack -w or the webpack-dev-server.

my config/webpacker.yml contains

production:
  <<: *default

  # Production depends on precompilation of packs prior to booting for performance.
  compile: true

  # Extract and emit a css file
  extract_css: true

  # Cache manifest.json for performance
  cache_manifest: true

2. webpack has not yet re-run to reflect updates.

I run

$ RAILS_ENV=production bundle exec rails webpacker:compile

3. You have misconfigured Webpacker's config/webpacker.yml file.

in development environment webpacker works correctly.

4. Your webpack configuration is not creating a manifest.

manifest.json is created

Eimantas
  • 48,927
  • 17
  • 132
  • 168
阿吽no呼吸
  • 231
  • 1
  • 2
  • 3

5 Answers5

28

I have the same issue when I run pre-built rails 6 app.Found out it is because of Webpack version inconsistency in yarn.lock file. Then when I run

yarn add @rails/webpacker

bundle update webpacker

as found in this comment , issue's solved.

Hung Om
  • 630
  • 7
  • 16
3

Remove Webpacker:

rm -rf bin/webpack*

Install Webpacker:

rails webpacker:install

Compile by Webpacker in production mode:

RAILS_ENV=production rails webpacker:compile

About this

shilovk
  • 11,718
  • 17
  • 75
  • 74
  • Should the command to do webpacker:compile be run on heroku using the heroku bash command? – Obromios Feb 23 '22 at 22:50
  • @Obromios May be, try it there – shilovk Feb 25 '22 at 23:09
  • That did not work. Eventually I solved it by removing my stylesheet_pack_tag from application.html, as per this answer: https://stackoverflow.com/questions/59161189/rails-webpacker-4-2-cant-find-application-in-app-public-packs-manifest-json-h/59162932#59162932. I could do this as I was not using webpacker to compile the apps css files. – Obromios Feb 26 '22 at 23:42
2

I'd the same problem. Just run in development environment:

rails webpacker:install

If you use Docker, run:

docker exec rails-app-name rails webpacker:install
0

If the manifest.json does not exist in your filesystem create it with rake assets:precompile.

Henry Ecker
  • 34,399
  • 18
  • 41
  • 57
krzyskk
  • 90
  • 1
  • 8
0

For me what worked was to replace <%= stylesheet_pack_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %> with <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %> In the application.html.erb file

Olivier Girardot
  • 389
  • 4
  • 16