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] Yarn does not work with WSL / UNC paths #1230

Closed
1 task
Stanzilla opened this issue Apr 21, 2020 · 10 comments · Fixed by #1246
Closed
1 task

[Bug] Yarn does not work with WSL / UNC paths #1230

Stanzilla opened this issue Apr 21, 2020 · 10 comments · Fixed by #1246
Assignees
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@Stanzilla
Copy link

  • I'd be willing to implement a fix

Describe the bug

Yarn does not work with WSL / UNC paths

To Reproduce

Run yarn on a project that is in a WSL container / UNC network share

Screenshots

If applicable, add screenshots to help explain your problem.
image

Environment if relevant (please complete the following information):

  • OS: Windows 10 2004
  • Node version 13.13.0
  • Yarn version [e.g. 2.0.0-rc1, ...] 2.0.0-rc.32

Additional context

Add any other context about the problem here.

@Stanzilla Stanzilla added the bug Something isn't working label Apr 21, 2020
@arcanis arcanis added the help wanted Extra attention is needed label Apr 21, 2020
@arcanis
Copy link
Member

arcanis commented Apr 21, 2020

This is likely a matter of adding support for such paths to fromPortablePath / toPortablePath.

@paul-soporan paul-soporan self-assigned this Apr 23, 2020
paul-soporan added a commit to paul-soporan/berry that referenced this issue Apr 23, 2020
arcanis pushed a commit that referenced this issue Apr 24, 2020
* feat(fslib): add support for UNC paths

Fixes #1230.
Tests are included.

* chore(release-workflow): set releases

* chore: run `yarn install` - the hashes of the ts patches changed

* fix: change PortablePath representation of UNC paths

* fix: change PortablePath representation of dot UNC paths
@Stanzilla
Copy link
Author

Stanzilla commented Apr 24, 2020

@arcanis @paul-soporan

PS Microsoft.PowerShell.Core\FileSystem::\\wsl$\Ubuntu\home\stan\projects\personal\WeakAurasCompanion> yarn
Internal Error: EPERM: operation not permitted, mkdir '\\wsl$\Ubuntu\unc'
Error: EPERM: operation not permitted, mkdir '\\wsl$\Ubuntu\unc'
PS Microsoft.PowerShell.Core\FileSystem::\\wsl$\Ubuntu\home\stan\projects\personal\WeakAurasCompanion> 

@paul-soporan paul-soporan reopened this Apr 25, 2020
@arcanis
Copy link
Member

arcanis commented Apr 25, 2020

@Stanzilla We currently can't reproduce it - can you dig a bit and post the stacktrace for the problematic mkdir call?

@Stanzilla
Copy link
Author

@arcanis how would I do that?

@paul-soporan
Copy link
Member

@Stanzilla Can you try the steps below and report back?

  1. Create a new project with a package manager that works in WSL 2.
  2. Add @yarnpkg/fslib, the package that contains our path and fs implementations.
  3. Test the following things inside WSL 2:
const {npath, xfs} = require(`@yarnpkg/fslib`);

// This is an alias for `C:\\` in Windows
const drivePath = npath.toPortablePath(`\\\\?\\C:\\`);
// Your WSL path
const wslPath = npath.toPortablePath(__dirname);

console.log(drivePath);
console.log(wslPath);

// Obviously, you don't have to give us the contents of your folders, just report if there's an error when executing these
console.log(xfs.readdirSync(drivePath));
console.log(xfs.readdirSync(wslPath));

The problem is that currently we can't reproduce your issue. Both the path implementation and the fs implementation seem to work.

@Stanzilla
Copy link
Author

❯ node test.js  
\\?\C:\
/home/stan/projects/personal/WeakAurasCompanion
internal/fs/utils.js:230
    throw err;
    ^

Error: ENOENT: no such file or directory, scandir '\\?\C:\'
    at Object.readdirSync (fs.js:968:3)
    at NodeFS.readdirSync (/home/stan/projects/personal/WeakAurasCompanion/node_modules/@yarnpkg/fslib/lib/NodeFS.js:250:32)
    at Object.<anonymous> (/home/stan/projects/personal/WeakAurasCompanion/test.js:12:17)
    at Module._compile (internal/modules/cjs/loader.js:1123:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1143:10)
    at Module.load (internal/modules/cjs/loader.js:972:32)
    at Function.Module._load (internal/modules/cjs/loader.js:872:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
    at internal/main/run_main_module.js:17:47 {
  errno: -2,
  syscall: 'scandir',
  code: 'ENOENT',
  path: '\\\\?\\C:\\'
}

@paul-soporan
Copy link
Member

My bad, I accidentally said "Run it in WSL 2" when I actually meant on Windows, but with the cwd inside the WSL container (Just like you originally tested Yarn when you opened the issue), so that you can test the UNC paths.

@Stanzilla
Copy link
Author

Stanzilla commented Apr 30, 2020

//?/C:/
//wsl$/Ubuntu/home/stan/projects/personal/yarntest
[
  '$Recycle.Bin',
  '$WinREAgent',
  'AeroGlass',
  'bootTel.dat',
  'Config.Msi',
  'Dell',
  'Documents and Settings',
  'DumpStack.log',
  'DumpStack.log.tmp',
  'Git',
  'OneDriveTemp',
  'pagefile.sys',
  'Program Files',
  'Program Files (x86)',
  'ProgramData',
  'Recovery',
  'Software',
  'swapfile.sys',
  'System Volume Information',
  'Users',
  'Windows',
  'wslgit'
]
[ 'node_modules', 'package.json', 'index.js', 'yarn.lock' ]

@Stanzilla
Copy link
Author

Tried again today:

➤ YN0000: Saving the new release in .yarn/releases/yarn-sources.js
➤ YN0001: Error: EPERM: operation not permitted, mkdir '\\wsl$\Ubuntu\unc'
➤ YN0000: Failed with errors in 2.91m

@merceyz
Copy link
Member

merceyz commented May 25, 2021

I can't reproduce the issue after #1246 got merged so I'll close this.


Tried again today:

➤ YN0000: Saving the new release in .yarn/releases/yarn-sources.js
➤ YN0001: Error: EPERM: operation not permitted, mkdir '\\wsl$\Ubuntu\unc'
➤ YN0000: Failed with errors in 2.91m

@Stanzilla It looks like you're trying to update to the new version using the version that doesn't support WSL paths, if I open a WSL path and run yarn set version berry && yarn set version 2.0.0-rc.36 && yarn then it fails as expected since it doesn't contain the fix, now if I run yarn set version 2.1.0 it also fails since 2.0.0-rc.36 is the one trying to write the update in the WSL path which it doesn't support. If you remove the yarnPath entry from .yarnrc.yml and run yarn set version berry it should work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants