Quantcast
Channel: ReScript Forum - Latest posts
Viewing all articles
Browse latest Browse all 2592

Help! VSCode tooling is broken for me on Windows

$
0
0

Gemini seems to think the issue is related to the path globs defined in server.ts.

      const watchers = Array.from(workspaceFolders).flatMap(
        (projectRootPath) => [
          {
            // Only watch the root compiler log for each workspace folder.
            // In monorepos, `**/lib/bs/.compiler.log` matches every package and dependency,
            // causing a burst of events per save.
            globPattern: path.join(projectRootPath, c.compilerLogPartialPath),
            kind: p.WatchKind.Change | p.WatchKind.Create | p.WatchKind.Delete,
          },
          {
            globPattern: path.join(
              projectRootPath,
              "**",
              c.buildNinjaPartialPath,
            ),
            kind: p.WatchKind.Change | p.WatchKind.Create | p.WatchKind.Delete,
          },
          {
            globPattern: `${
              path.join(projectRootPath, "**", c.compilerDirPartialPath)
            }/**/*.{cmt,cmi}`,
            kind: p.WatchKind.Change | p.WatchKind.Delete,
          },
        ],
      );

The Problem
In a VS Code Remote environment (like WSL), absolute path globs are notoriously flaky.

  1. Path Mismatch: The Server (in WSL) generates a Linux path (/home/josh/...). The Client (on Windows) receives this request. While VS Code should handle this mapping, explicitly pinning watchers to absolute paths often fails when the file system and UI live on different OS kernels.
  2. Glob Syntax: VS Code watchers work best with Relative Patterns (e.g., **/src/*.res). When you use absolute paths containing ** (like /home/josh/project/**/lib...), strict file system watchers often reject them or fail to bind them to the correct workspace root logic.

This is what it suggests:

// FIX: Use relative glob patterns instead of absolute paths.
// This ensures compatibility with WSL/Remote environments where
// absolute paths often fail to map correctly between Client (Windows) and Server (Linux).
const watchers = [
  {
    // Watch for compiler log (triggers build status)
    // Using **/ ensures we catch it even if the path structure varies slightly,
    // and relies on VS Code's native exclusion (files.watcherExclude) to ignore node_modules.
    globPattern: `**/${c.compilerLogPartialPath}`,
    kind: p.WatchKind.Change | p.WatchKind.Create | p.WatchKind.Delete,
  },
  {
    // Watch for ninja build files
    globPattern: `**/${c.buildNinjaPartialPath}`,
    kind: p.WatchKind.Change | p.WatchKind.Create | p.WatchKind.Delete,
  },
  {
    // Watch for binary artifacts (.cmt/.cmi) to trigger diagnostics updates
    globPattern: `**/${c.compilerDirPartialPath}/**/*.{cmt,cmi}`,
    kind: p.WatchKind.Change | p.WatchKind.Delete,
  },
];

I tried testing it out locally, but I couldn’t get the local extension to run (perhaps another wsl issue…)


Viewing all articles
Browse latest Browse all 2592

Trending Articles