Webpacker: Yarn install runs twice after upgrading to 4.2.0

Created on 15 Nov 2019  路  9Comments  路  Source: rails/webpacker

Running bundle exec rake assets:precompile now runs yarn install twice: (This didn't happen with 4.0.7)

yarn install v1.19.1
[1/4] Resolving packages...
success Already up-to-date.
Done in 1.66s.
yarn install v1.19.1
[1/4] Resolving packages...
success Already up-to-date.
Done in 2.00s.
Everything's up-to-date. Nothing to do

Also now when deploying (capistrano) yarn install always fetches packages (it never says "already up-to-date" anymore). This wasn't the case with 4.0.7 (node_modules and public/packs are in the linked_dirs option)

Rails 6.0.1
Webpacker 4.2.0

Most helpful comment

Thanks for the fix @gauravtiwari, look like the fix made it to master but there hasn't been a release in almost 2 months, do you know if this is likely to be available soon? Cheers!

All 9 comments

yup it ran twice on my machine too

Running twice in my app as well

[aolmode]me too[/aolmode]

strange, everything works, but duplicated.

```01 ~/.rvm/bin/rvm 2.6.5 do bundle exec rake assets:precompile
01 yarn install v1.19.2
01 [1/4] Resolving packages...
01 [2/4] Fetching packages...
01 info [email protected]: The platform "linux" is incompatible with this module.
01 info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
01 [3/4] Linking dependencies...
01 [4/4] Building fresh packages...
01 Done in 11.92s.
01 yarn install v1.19.2
01 [1/4] Resolving packages...
01 [2/4] Fetching packages...
01 info [email protected]: The platform "linux" is incompatible with this module.
01 info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
01 [3/4] Linking dependencies...
01 [4/4] Building fresh packages...
01 Done in 4.75s.
01 Compiling...

Yap, can confirm on webpacker 4.2.2. A fix for this would be nice

Running twice in my app as well (2)

@gauravtiwari any idea?

This issue occurs with the following code:

https://github.com/rails/webpacker/blob/96af013eed295576ac246f46dee1d01d67888801/lib/tasks/webpacker/yarn_install.rake#L16-L21

The code is executed before defining the yarn:install in railties, and the condition always returns false.

If you want to fix the issue immediately, you can fix it by removing webpacker:yarn_install in the Rakefile.

require_relative 'config/application'

Rails.application.load_tasks

# Remove `webpacker:yarn_install` task
#
# ref: https://github.com/rails/webpacker/issues/2369
Rake::Task['yarn:install'].tap do |t|
  raise 'Consider removing this patch' unless t.prerequisites.include?('webpacker:yarn_install')

  prerequisites = t.prerequisites - ['webpacker:yarn_install']
  t.clear_prerequisites
  t.enhance(prerequisites) unless prerequisites.empty?
end

This is now fixed 馃憤

Thanks for the fix @gauravtiwari, look like the fix made it to master but there hasn't been a release in almost 2 months, do you know if this is likely to be available soon? Cheers!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

inopinatus picture inopinatus  路  3Comments

johan-smits picture johan-smits  路  3Comments

ankitrg picture ankitrg  路  3Comments

towry picture towry  路  3Comments

ijdickinson picture ijdickinson  路  3Comments