-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Resolve scoped package paths during linking on Windows #1866
Resolve scoped package paths during linking on Windows #1866
Conversation
Note: This is the change that #1862 was supposed to contain. Apologies for adding to the noise with my initial mistake! |
Thanks, @dpoindexter. Is it a regression since release 0.16.1? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unit test would be much appreciated
Not a regression -- it's been this way since at least 0.15 as far as I can tell. I'll add tests. |
f8c836d
to
7fca0c8
Compare
Added a unit test, and edited the PR description to reflect the updated approach. I rebased onto most recent master before pushing these updates-- is there something I need to mark to show that I've made the requested review changes? |
@dpoindexter, nothing you need to mark, just comment that you made the requested changes, which you did. |
@dpoindexter, thanks a lot for the test! |
what is the status on publiching this fix ? im getting the @types problem so i guess its yet not out ? |
Summary
Resolves #1861.
The above issue is Windows-specific. It's caused by the step that unlinks extraneous packages. This compares a Set
possibleExtraneous
against a Set of pathsfiles
resolved during bulk copy.The problem is how paths are added to the
files
Set. yarn attempts to add all path segments tofiles
by splitting the destination path onpath.sep
. This works as expected on Posix systems, where the path separator is the same as the scoped package name delimiter:project/node_modules/@scoped/dep/node_modules/subdep
But on Windows, the destination path is constructed naively from the package name:
project\\node_modules\\@scoped/dep\\node_modules\\subdep
possibleExtraneous
, having been resolved from reading directories on disk rather than from thepackage.json
contains the correct Windows path:project\\node_modules\\@scoped\\dep\\node_modules\\subdep
possibleExtraneous
then checks to see if its members are present infiles
. Any that are are not considered extraneous. Because of the above difference in the path string, scoped subdirectories are wrongly seen as extraneous, and deleted.What changed
It was difficult for me to tell what was intended behavior in other parts of the system, so I constrained this change to the two places that file paths are added to the non-extraneousfiles
collection during the bulk copy operation. I'm callingpath.normalize
on each destination path before it's split bypath.sep
. This resolves the separator inconsistency caused by scoped package names.My change now resolves the issue by normalizing the destination path returned by
PackageHoister.init
. As far as I can tell, this is only ever used as a filesystem path downstream, so this should be safe.Test plan
Automated:
The included unit test demonstrates the failing case when run on Windows with the change reverted.
Manual:
The repro steps in the linked issue demonstrate that this is resolved on Windows.
yarn add
a scoped package (ex.@cycle/http
)yarn add
any dependency of the scoped package, at an incompatible version (ex.[email protected]
) (This prevents the subdependency of the scoped package from hoisting)yarn add
a second time