-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[Enhancement]: yarn on Windows with nodeLinker set to node-modules creates symlinks as absolute paths in node_modules folder #4979
Comments
It is expected, nm linker uses junctions instead of symlinks on Windows. Junctions are available on all versions of Windows. Plus the main point of nm linker is compatibility with Yarn v1, which used junctions as well. You can check that Yarn v1 behaves the same: I think it is okay to have experimental support for using symlinks on Windows, but their usage should be behind configuration parameter, which will use junctions by default. Turning symlinks on Windows is an unknown territory, I'm afraid many users might be affected if we turn it on by default without extensive testing it first. |
Ok, that explains the situation, but for my multi-platform dev team (some folks on Linux, some on Windows) the difference in behavior is definitely causing problems. I like the idea of a configurable SymLink option--I am new to Yarn and was in fact looking for a 'relative symlinks' option in the .yarnrc.yml docs. I'd be happy to experiment with this a proposed a PR. I started digging through the nm linker code a bit but haven't pulled all the threads on the fsutils, ppath and other helpers to find where the juntions are actually created. If you can point me to the general section, it'd be a help! (though I'm guessing I can search for 'junction' and find it...) |
Bingo!
|
@larixer I have a fork off of Master (so 4.0.0-rcX) which adds the option (not 100% sure I got the versions correct) Before I make a PR, question: should it make the PR to master or to a 3.x branch? Thanks! |
Changing the title from [Bug] to [Enhancement]--I don't appear to have perms to change the label. |
Here's the PR--not sure I got the versions correct,. Changes are exclusive to nm-linker plugin, so just bumped plugin-nm and cli . not sure if everything that depends on CLI (other plugins) needs bumping as well? |
Nothing else needs to be bumped in this case 👍 |
Self-service
Describe the bug
Yarn 3.2.4
Windows 10
Node 18.x
Docker
node-linker
Running 'yarn install' on multiple workspaces that use 'portal:' or 'workspace:' to reference other workspaces results in symlinks in the top level node_modules that are absolute paths.
Running 'yarn install' on the same monorepo creates symlinks with relative paths, as expected.
The issue is with mounting the filesystem into Docker containers for running consistent builds.
The absolute paths are broken in Docker because we mount just the project directory as a Docker volume, not an entire hard drive.
Relative paths, as created in Yarn on Linux work correctly,
E.g.
Partial listing of node_modules when
yarn install
is run on Linux:vs. exact same repo, but
yarn install
run from WIndows:To reproduce
// sorry, this issue is only windows, so sherlock can't be used. Instead here are high-level reproduction steps
yarn init -2
.yarnrc.yml
to set nodeLiker tonode-modules
workspaces: packages/*
From WINDOWS run
yarn install
NOTICE: the link created in
node_modules
is absolute not relativeEnvironment
Additional context
No response
The text was updated successfully, but these errors were encountered: