Hi,
you guys added recently a new task webpacker:clean which doesn't work for us. Unfortunately we can't prevent this task either because you add it to assets:clean without giving an option to disable it. Would be great if you could add this.
The error is:
Errno::ENOENT: No such file or directory @ apply2files - /var/local/kenhub/kenhub.d/1126/public/packs/application-975ab57e9c1b40f7ec06.js
/var/local/kenhub/kenhub.d/1126/vendor/bundle/ruby/2.5.0/gems/webpacker-4.2.0/lib/webpacker/commands.rb:21:in `delete'
/var/local/kenhub/kenhub.d/1126/vendor/bundle/ruby/2.5.0/gems/webpacker-4.2.0/lib/webpacker/commands.rb:21:in `block in clean'
/var/local/kenhub/kenhub.d/1126/vendor/bundle/ruby/2.5.0/gems/webpacker-4.2.0/lib/webpacker/commands.rb:21:in `each'
/var/local/kenhub/kenhub.d/1126/vendor/bundle/ruby/2.5.0/gems/webpacker-4.2.0/lib/webpacker/commands.rb:21:in `clean'
/var/local/kenhub/kenhub.d/1126/vendor/bundle/ruby/2.5.0/gems/webpacker-4.2.0/lib/webpacker.rb:27:in `clean'
/var/local/kenhub/kenhub.d/1126/vendor/bundle/ruby/2.5.0/gems/webpacker-4.2.0/lib/tasks/webpacker/clean.rake:6:in `block (2 levels) in <top (required)>'
/var/local/kenhub/kenhub.d/1126/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/exe/rake:27:in `<top (required)>'
/usr/bin/bundle:23:in `load'
/usr/bin/bundle:23:in `<main>'
We can see in public/packs that these files exist before
application-975ab57e9c1b40f7ec06.js
application-975ab57e9c1b40f7ec06.js.gz
application-975ab57e9c1b40f7ec06.js.map
application-975ab57e9c1b40f7ec06.js.map.gz
but then something in webpacker:clean removes
application-975ab57e9c1b40f7ec06.js
application-975ab57e9c1b40f7ec06.js.gz
and then also complains that thay don't exist anymore.
Also have the same issue. I did a bit of debug and it's basically occurring because of gz compressed assets. The code in this method https://github.com/LuanGB/webpacker/blob/0c7a9f750ddf3a4fd9a6ad9f91331c80b15c20fd/lib/webpacker/commands.rb#L8 matches finds the original and compressed js file However the ext only pickups up .js As such it tries to delete the js file twice rather than delete the .js and delete .js.gz
I'm encountering this consistently on our CI and Heroku, the only solution is to clear the whole cache.
Issue can recreated easily:
bin/rails assets:clobberbin/rails assets:precompile && assets:clean console.log to js filesEDIT: recreate instructions
This solution worked for us, will be great if you can test this patch https://github.com/rails/webpacker/pull/2382
@tachyons your patch worked great for me.
Looking at it, I wonder if ignoring the Errno::ENOENT errors from File.delete would also make sense. Ideally it would always receive the right files, but there's also no reason to bail so loudly in a "clean" task if a file has already been removed.
I was still running into this error due to missing files, so created a follow up PR that ignores missing file errors: https://github.com/rails/webpacker/pull/2384
@aleksejleonov Sorry, You mean you are still getting missing file error after applying my patch ?
https://github.com/rails/webpacker/pull/2385 - possible solution
Most helpful comment
Also have the same issue. I did a bit of debug and it's basically occurring because of gz compressed assets. The code in this method https://github.com/LuanGB/webpacker/blob/0c7a9f750ddf3a4fd9a6ad9f91331c80b15c20fd/lib/webpacker/commands.rb#L8 matches finds the original and compressed js file However the ext only pickups up .js As such it tries to delete the js file twice rather than delete the .js and delete .js.gz