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

Ignored Files and Folders are still watched in WSL #1418

Open
Pragadesh-45 opened this issue Mar 12, 2025 · 1 comment
Open

Ignored Files and Folders are still watched in WSL #1418

Pragadesh-45 opened this issue Mar 12, 2025 · 1 comment

Comments

@Pragadesh-45
Copy link

Describe the bug

There is an issue with ignored folders when WSL paths are accessed from Windows. I suspect the issue lies in the normalizePathToUnix(sp.isAbsolute(path) ? path : sp.join(cwd, path)) function. [Code reference](

return normalizePathToUnix(sp.isAbsolute(path) ? path : sp.join(cwd, path));
)

Versions (please complete the following information):

  • Chokidar version: 3.5.3
  • Node version: v20.18.1
  • OS version: Windows 11

Additional context

I suspect the issue lies in the toUnix function, which is defined for the ignored path. It returns an invalid path when invoked with a valid WSL path.

Example:

> toUnix('\\wsl.localhost\Ubuntu\home\codex_wsl\one-wsl')
'/wsl.localhostUbuntuhomecodex_wslone-wsl'

The current logic is as follows:
https://github.com/paulmillr/chokidar/blob/916334c8a30eb8340f3b6602267ab23a9e31abd0/src/index.ts#L163C1-L178C3

// If SLASH_SLASH occurs at the beginning of the path, it is not replaced
//     because "//StoragePC/DrivePool/Movies" is a valid network path
const toUnix = (string: string) => {
  let str = string.replace(BACK_SLASH_RE, SLASH);
  let prepend = false;
  if (str.startsWith(SLASH_SLASH)) {
    prepend = true;
  }
  while (str.match(DOUBLE_SLASH_RE)) {
    str = str.replace(DOUBLE_SLASH_RE, SLASH);
  }
  if (prepend) {
    str = SLASH + str;
  }
  return str;
};

This logic handles some network paths like smb://192.168.1.10/folder (SMB on Linux), but it fails when accessing SMB and WSL paths from Windows, e.g., \\fileserver\sharedfolder and \\wsl.localhost\Ubuntu\home.

@Pragadesh-45 Pragadesh-45 changed the title Ignored Files and Folders are still watched Ignored Files and Folders are still watched in WSL Mar 12, 2025
@43081j
Copy link
Collaborator

43081j commented Mar 17, 2025

can you provide a reproduction?

you've explained what you think the fix is, but not what the problem is

also, your example is slightly wrong since the string would be escaped if you passed a string literal:

> toUnix('\\\\wsl.localhost\\Ubuntu\\home\\codex_wsl\\one-wsl')
'//wsl.localhost/Ubuntu/home/codex_wsl/one-wsl

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants