Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New webpacker:clean task raises 'No such file or directory' error #2372

Closed
joker-777 opened this issue Nov 20, 2019 · 6 comments · Fixed by #2389
Closed

New webpacker:clean task raises 'No such file or directory' error #2372

joker-777 opened this issue Nov 20, 2019 · 6 comments · Fixed by #2389

Comments

@joker-777
Copy link
Contributor

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.

@georgepalmer
Copy link

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

@kpheasey
Copy link

kpheasey commented Nov 27, 2019

I'm encountering this consistently on our CI and Heroku, the only solution is to clear the whole cache.

Issue can recreated easily:

  1. run bin/rails assets:clobber
  2. run bin/rails assets:precompile && assets:clean
  3. make some random changes like adding console.log to js files
  4. repeat steps 2 and 3 at least 6 times (or however many versions you keep)

EDIT: recreate instructions

@tachyons
Copy link
Contributor

tachyons commented Dec 1, 2019

This solution worked for us, will be great if you can test this patch #2382

@alexdunae
Copy link

alexdunae commented Dec 2, 2019

@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: #2384

alexdunae added a commit to alexdunae/webpacker that referenced this issue Dec 3, 2019
alexdunae added a commit to alexdunae/webpacker that referenced this issue Dec 3, 2019
@tachyons
Copy link
Contributor

tachyons commented Dec 3, 2019

@aleksejleonov Sorry, You mean you are still getting missing file error after applying my patch ?

@le0pard
Copy link

le0pard commented Dec 4, 2019

#2385 - possible solution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
6 participants