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

[Bug] Patched fs doesn't account for the __virtual__ folder and its immediate children #2959

Open
1 task
merceyz opened this issue May 30, 2021 · 5 comments
Open
1 task
Labels
bug Something isn't working reproducible This issue can be successfully reproduced

Comments

@merceyz
Copy link
Member

merceyz commented May 30, 2021

  • I'd be willing to implement a fix

Describe the bug

The result of calling fs.readdir on <pwd>/.yarn doesn't include __virtual__ and its immediate children making libraries like chokidar unable to detect changes to virtual files (read: workspaces with peer dependencies)

To Reproduce

Reproduction
const fs = require('fs')

const installPromise = packageJsonAndInstall({
dependencies: {
  [`react-dom`]: `17.0.0`,
},
});

await expect(installPromise).resolves.toBeTruthy();

expect(fs.readdirSync(process.cwd() + '/.yarn')).toContain('__virtual__');

Environment if relevant (please complete the following information):

  • OS: Windows 10
  • Node: v16.2.0
  • Yarn: 3.0.0-rc.2
@merceyz merceyz added the bug Something isn't working label May 30, 2021
@yarnbot yarnbot added the reproducible This issue can be successfully reproduced label May 30, 2021
@yarnbot
Copy link
Collaborator

yarnbot commented May 30, 2021

This issue reproduces on master:

Error: expect(received).toContain(expected) // indexOf

Expected value: "__virtual__"
Received array: ["cache", "install-state.gz"]
    at module.exports (evalmachine.<anonymous>:12:50)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async /github/workspace/.yarn/cache/@arcanis-sherlock-npm-2.0.2-91650a2501-627bee24a7.zip/node_modules/@arcanis/sherlock/lib/executeRepro.js:56:13
    at async executeInTempDirectory (/github/workspace/.yarn/cache/@arcanis-sherlock-npm-2.0.2-91650a2501-627bee24a7.zip/node_modules/@arcanis/sherlock/lib/executeRepro.js:17:16)
    at async Object.executeRepro (/github/workspace/.yarn/cache/@arcanis-sherlock-npm-2.0.2-91650a2501-627bee24a7.zip/node_modules/@arcanis/sherlock/lib/executeRepro.js:24:12)
    at async ExecCommand.execute (/github/workspace/.yarn/cache/@arcanis-sherlock-npm-2.0.2-91650a2501-627bee24a7.zip/node_modules/@arcanis/sherlock/lib/commands/exec.js:25:38)
    at async ExecCommand.validateAndExecute (/github/workspace/.yarn/cache/clipanion-npm-2.0.0-rc.16-b9444aaf89-91cf93ba72.zip/node_modules/clipanion/lib/advanced/Command.js:161:26)
    at async Cli.run (/github/workspace/.yarn/cache/clipanion-npm-2.0.0-rc.16-b9444aaf89-91cf93ba72.zip/node_modules/clipanion/lib/advanced/Cli.js:74:24)
    at async Cli.runExit (/github/workspace/.yarn/cache/clipanion-npm-2.0.0-rc.16-b9444aaf89-91cf93ba72.zip/node_modules/clipanion/lib/advanced/Cli.js:83:28)

@arcanis
Copy link
Member

arcanis commented May 30, 2021

I'm not sure it's a bug, more like a limitation - the folder doesn't really exist, so it probably shouldn't be returned. Even if we could, there's by design an infinity of possible virtual paths, which couldn't be represented on the disk. We potentially could only show those that are in the PnP map, but it remains to see how much complexity it would add 🤔

@kepta
Copy link

kepta commented May 30, 2021

Wanted to add that this is a blocker for using modern tools like Vite which depend on chokidar to watch for any changes in linked packaged.

@missing1984
Copy link
Contributor

+1 on this. I've used pnp for more than a year and this is one of the bugs that keep frustrated me.

@DiFuks
Copy link

DiFuks commented Feb 15, 2024

This issue has been interfering with the operation of Vite since version 5.1.0 vitejs/vite#15910 (comment)

There is a workaround, but it seems that this problem should be fixed on the yarn side.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working reproducible This issue can be successfully reproduced
Projects
None yet
Development

No branches or pull requests

6 participants