question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug?]: `yarn dlx` breaks with hardlinked node modules

See original GitHub issue

Self-service

  • I’d be willing to implement a fix

Describe the bug

yarn dlx breaks when nmMode is set to hardlinks-[local/global]

To reproduce

await yarn('init', '-y');
await yarn('config', 'set', 'enableGlobalCache', 'true');
await yarn('config', 'set', 'nodeLinker', 'node-modules');
await yarn('config', 'set', 'nmMode', 'hardlinks-global');

await expect(yarn('dlx', 'sirv-cli', '-v')).rejects.not.toThrow();

Environment

System: OS: Linux 5.12 Arch Linux CPU: (4) x64 Intel® Core™ i3-5005U CPU @ 2.00GHz Binaries: Node: 16.5.0 - /tmp/xfs-c1cde8a3/node Yarn: 3.0.0 - /tmp/xfs-c1cde8a3/yarn npm: 7.20.0 - ~/.local/npm-global/bin/npm

Additional context

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

3reactions
merceyzcommented, Jul 27, 2021

If we can’t make sure they are, maybe we should not use hardlinks for dlx, then? How do we detect that we are linking under dlx in the latter case?

We can set dlx specific settings like I did in https://github.com/yarnpkg/berry/pull/2677 but we should probably not make that the solution in this case since any project can be on a different device than the cache, perhaps we could gracefully downgrade to hardlinks-local

0reactions
merceyzcommented, Jul 30, 2021

Why not force nmMode: classic for dlx?

Since it would only fix yarn dlx and wouldn’t help for cases like https://github.com/yarnpkg/berry/issues/3191

I can add smart code to dlx, to detect whether it is possible to create hardlinks between the three and depending on the result either use hardlinkks-global, hardlinks-local or classic, but it seems too complex for the little gain. Its much easier to just force nmMode:: classic if nm linker is used for dlx, what do you think?

I write this after looking at https://github.com/yarnpkg/berry/pull/3204 but I think just making the linker fallback to hardlinks-local in general is good enough, it’s unlikely that different parts of the node_modules folder is on different devices

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot find module (any module) using PnP · Issue #3458 ...
Self-service I'd be willing to implement a fix Describe the bug Something went very wrong with my yarn install I think.
Read more >
Introducing Yarn 2 ! 🧶🌟 - DEV Community 👩‍💻👨‍💻
The yarn package on npm will not change; we will distribute further ... Yarn 2 introduces a new command called yarn dlx (dlx...
Read more >
@yarnpkg/plugin-dlx | Yarn - Package Manager
Peer dependencies depending on their own parent are now properly hoisted by the node-modules linker. Boolean values will be properly interpreted when specified ......
Read more >
Migration | Yarn - JavaScript 软件包管理器
Any major release has its breaking changes, and Yarn 2 isn't the exception. A few old behaviors were cleaned, fixed, modified, or removed....
Read more >
After creating a React app with yarn dlx ...
js". My solution was to disable plug'n'play by setting nodeLinker: node-modules in .yarnrc.yml.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found