Webpack - Troubleshooting

[Webpacker] Rails assets manifest file not found

$ cap production deploy
03:04 deploy:assets:backup_manifest
      01 mkdir -p /home/sith/production/releases/20180522104043/assets_manifest_backup
      WARN  Rails assets manifest file not found.
Caused by:
Capistrano::FileNotFound: Rails assets manifest file not found.


Capistrano runs deploy:assets:precompile and deploy:assets:backup_manifest tasks when performing deployment if you require capistrano/rails/assets file:

# Capfile

require 'capistrano/rails/assets'

deploy:assets:backup_manifest task fails because it cannot find manifest in public/packs/ - this is because Capistrano searches for manifest this way:

# https://github.com/capistrano/rails/blob/master/lib/capistrano/tasks/assets.rake#L104

def detect_manifest_path
  ).each do |pattern|
    candidate = release_path.join('public', fetch(:assets_prefix), pattern)
    return capture(:ls, candidate).strip.gsub(/(\r|\n)/,' ') if test(:ls, candidate)
  msg = 'Rails assets manifest file not found.'
  warn msg
  fail Capistrano::FileNotFound, msg

by default assets_prefix option in Capistrano config (config/deploy.rb) is set to assets so deploy:assets:backup_manifest task searches for manifest inside public/assets/ directory which doesn’t even exist: webpacker:compile task creates public/packs/ directory (public_output_path option in Webpacker config) to store compiled assets.

so there are 2 possible solutions to this problem: