Skip to content

Ignored Files and Folders are still watched in WSL #1418

@Pragadesh-45

Description

@Pragadesh-45

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions