Do you want to request a feature or report a bug?
bug
What is the current behavior?
If I stop yarn during Linking dependencies (via ^C, for example because I made a mistake and wanted to stop and add --dev) then when installing any new package, compiled files in unrelated packages are removed and not recompiled properly.
If the current behavior is a bug, please provide the steps to reproduce.
mkdir test-bug
cd test-bug
yarn init
yarn add node-sass
ls node_modules/node-sass # the vendor directory is correctly there
yarn add react # press ^C (ctrl+C) during "Linking dependencies" phase
ls node_modules/node-sass # the vendor directory is still there
yarn add react
ls node_modules/node-sass # (!) the vendor directory is gone
What is the expected behavior?
Yarn should either not remove compiled binaries if "Linking dependencies" step has been interrupted or recompile them afterwards.
Please mention your node.js, yarn and operating system version.
yarn: 0.24.6
node: v8.1.2
OS: macOS 10.12.15
Thanks, @d4rky-pl.
Yeah, yarn should be atomic and should indicate that install scripts started but have not finished.
The logic is in package-linker.js, help is welcome
Furthering d4rky-pl's reproduction steps:
mkdir test-bug
cd test-bug
yarn init
yarn add node-sass
ls node_modules/node-sass/vendor # the vendor contents are correctly there
# Simulate the user/system exiting during the linking step
# The linking step removes the `.yarn-integrity` file
rm node_modules/.yarn-integrity
yarn
ls node_modules/node-sass/vendor # (!) the vendor contents are gone
It seems to be the deletion of the integrity file means the package-linker no longer has context of module artifacts the next time yarn is invoked.
If the integrity file is missing on init of yarn, should it do a force install of all modules (like yarn remove)?
Happy to help, if someone can point me in the right direction 馃樃
@jamsinclair I think you are right.
Some pointers:
https://github.com/yarnpkg/yarn/blob/master/src/cli/commands/install.js#L350 - this is where Yarn does the integrity check and can know if .yarn-integrity exists
https://github.com/yarnpkg/yarn/blob/master/src/cli/commands/install.js#L481 - this is where it runs scripts.
It is strange that it does not run the scripts in this case, yarn 0.28 should do it.
@BYK @bestander @kaylieEB Looks closeable per #4185
Thanks again @olingern ! 馃帀
Most helpful comment
Thanks again @olingern ! 馃帀