-
Notifications
You must be signed in to change notification settings - Fork 242
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
Ensure local dependencies are properly copied on Windows #705
Conversation
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.
Makes the tests pass for me 🥇
This comment has been minimized.
This comment has been minimized.
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.
It looks nice!
As this PR, I feel that copy is better than link.
because in some case the directory owner is different user.
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.
Looks good to me.
Wow, this seems to fix quite a few obscure problems. Nice work on the debugging everyone! 👍 Could you explain what exactly went wrong with the previous version of the code and how adding the If the source is a link, will the destination be a link too, or an actual copy of the folder pointed to by the source link? |
This is the code Previosuly, this did use Now, with the option, In normal usage of the method this is possibly not even a problem, but in the test setup the |
Thanks for the details @janpio. What about my last question? Do you know how the new code behaves?
|
Not really, I would have to check (but on a Chromebook right now). I had a solution that created another symlink (with junction, whatever that is exactly) but it was an ugly hack that circumvented fs.copySync completely and @oliversalzburg 's actually uses the code how it should be used I think. |
To summarize the issue and solution: When you Windows distinguishes between different types of links, just like UNIX does, but differently. The most important distinctions are between file and directory symlinks and junctions (or reparse points). Instinctively, every developer would want to just use symlinks on Windows as well, but junctions are usually preferable. A symlink on Windows is much more versatile, but we usually don't care about the extra functionality and we also don't want to care about the file/directory distinction. For all intents and purposes, a junction is the way to go. As junctions can only be used to link directories and symbolic links are problematic, you are left with the limitation that you can really only easily and properly link directories on Windows. So when you instruct NodeJS to create a symlink on Windows and you don't pass a third argument, NodeJS will create a file symlink. This will usually fail, because the user is not allowed to create symlinks. That is one of the main reasons to always use junctions on Windows. Now when we're instructing So by passing I'm not sure why |
Alright, thanks for the detailed explanation @oliversalzburg. I was mainly interested in the second part (specific to this issue; was already familiar with the general linking behavior of npm and Windows). Since we have a dedicated option for when we actually want to create a link, I think this fix is fine. It would be nice to have a test to verify the behavior for when the source is a link. But we can merge this either way. We might even consider the behavior of fs-extra buggy. Shouldn't it check the source link's type when copying it and create a link of matching type? |
I think so, yeah. I opened jprichardson/node-fs-extra#626 to discuss this with the authors. |
I think this is the most-approved PR I've seen here thus far 😁 |
Platforms affected
All
What does this PR do?
Ensures that dependencies are properly copied when the source is a symlink/junction.
What testing has been done on this change?
E2E test suite has been run and now finally passes on Windows.
Checklist