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

Yarn removes compiled libraries if "Linking dependencies" was interrupted by user #3752

Closed
d4rky-pl opened this issue Jun 29, 2017 · 5 comments

Comments

@d4rky-pl
Copy link

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

@bestander
Copy link
Member

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

@jamsinclair
Copy link
Contributor

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 😸

@bestander
Copy link
Member

@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.

@olingern
Copy link
Contributor

@BYK @bestander @kaylieEB Looks closeable per #4185

@kaylie-alexa
Copy link
Member

Thanks again @olingern ! 🎉

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

No branches or pull requests

5 participants