capistrano / rails

Official Ruby on Rails specific tasks for Capistrano
http://www.capistranorb.com/
MIT License
867 stars 270 forks source link

Deploying a webpacker project without sprockets fails #235

Open chemic opened 4 years ago

chemic commented 4 years ago

Steps to reproduce

Deploy a project with assets built with Webpacker and without sprockets generating anything.

Expected behavior

Deploy succeeds

Actual behavior

Deploy fails because manifest files are missing

 DEBUG [a53efae3]   cannot access '/home/deploy/appname/releases/20190911225157/public/assets/.sprockets-manifest*'
 DEBUG [a53efae3]   : No such file or directory
 DEBUG [769a050c]   cannot access '/home/deploy/appname/releases/20190911225157/public/assets/manifest*.*'
 DEBUG [769a050c]   : No such file or directory

Hot-Fix

Adding a line to deploy.rb Rake::Task["deploy:assets:backup_manifest"].clear_actions

mattbrictson commented 4 years ago

I can think of two solutions:

  1. We already have a :assets_manifests setting. We could add some conditional logic that if :assets_manifests is empty or nil then we skip the backup_manifest task.
  2. We introduce a new set of tasks specifically for webpacker-only projects. If you are using sprockets, you would use require "capistrano/rails/assets" as you do today. If you are using webpacker only, then you would use require "capistrano/rails/webpacker" instead.

I kind of like the second option because we can support the next generation of Rails apps using a clean slate rather than hacking the existing tasks with more and more conditional logic. But, the second option is definitely more work. I do not use Capistrano with webpacker so I would need help from the community to put a PR together.

Option 1 is fairly easy and I could hack something together for that pretty quickly.

Thoughts?

chemic commented 4 years ago

+1 for the 2nd approach from my side as well, looks cleaner and more future proof :)

mattbrictson commented 4 years ago

OK I put a you can help! label on this issue to indicate that I am looking for the community to provide a PR. Please open one if you have a suggested implementation! 🙏

b-nik commented 4 years ago

Does setting the asset_prefix like recommended below work? It worked for me.

http://blog.tap349.com/webpack/2018/05/22/webpack-troubleshooting/

edit: I actually had to enable sprockets because of various issues without it :(

patleb commented 4 years ago

This pull request is necessary when using webpacker and set :assets_prefix, 'packs'.

ghost commented 4 years ago

Rollback is getting failed when i use set :assets_prefix, 'packs' Rails assets manifest file (or backup file) not found. Pls anyone can help me