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

fix(nm): Reinstall removed module directories #3467

Merged
merged 8 commits into from Mar 22, 2022

Conversation

larixer
Copy link
Member

@larixer larixer commented Sep 21, 2021

What's the problem this PR addresses?

When you remove unplugged directory with pnp linker, it reinstalls the directory again. This behaviour is currently different for the nm linker, it will perform reinstall only when top-level nm folder is removed. The PR changes this for the nm linker, so that both linkers behave the same - when you remove directory deep inside node_modules the nm linker reinstalls only this directory and rebuilds the module if needed. The same logic applies to the bin symlinks - removed bin symlinks gets recreated by the nm linker.

Closes #3214

How did you fix it?

I use the fact that the nm linker writes node_modules/.yarn-state.yml as the last operation of the link step, hence it must have the mtime which is greater than all the files and folders inside node_modules. To detect whether the user has removed any module directory inside node_modules, it is enough to check whether each parent node_modules folder has mtime >= state_file_mtime and if it does - the user has modified the directory, we then perform readdir and find entries deleted by the user, if any, and record these modifications in the preinstall state. The algorithm that diffs install and preinstall state later does the rest of the job of reinstall deleted modules and directories.

Checklist

  • I have set the packages that need to be released for my changes to be effective.
  • I will check that all automated PR checks pass before the PR gets reviewed.

@larixer larixer changed the title fix(nm): Reinstall removed modules directories fix(nm): Reinstall removed module directories Sep 21, 2021
@penx
Copy link

penx commented Mar 21, 2022

@arcanis @merceyz is there anything that can be done to get this in? 🙏

@larixer larixer requested a review from merceyz March 22, 2022 13:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug?]: yarn install error ENOENT: no such file or directory
3 participants