SIGN IN SIGN UP

fix(core): compare daemon workspace roots case-insensitively on Windows (#36835)

`isForeignWorkspaceMessage` compared the sender's and the receiver's
workspace root with a raw `!==`, on the assumption recorded in its own
doc comment that "both come from the same resolution". They do not
always come from the same branch of it: `workspaceRootInner` returns
`NX_WORKSPACE_ROOT_PATH` verbatim when that variable is set, while the
fallback walks up from `process.cwd()`.

On Windows those two sources routinely disagree on the case of the drive
letter. An editor or coding agent exports `d:\repo` while
`process.cwd()` reports `D:\repo`. Windows paths are case-insensitive,
and a drive letter is case-insensitive without exception, so both spell
the same directory - but the daemon read the second spelling as a
foreign workspace and refused every message from whichever shell did not
start it:

The Nx Daemon for 'd:\repo' received a message from a different
workspace
    ('D:\repo') and refused to process it.

The check is meant to catch two genuinely different workspaces sharing
an NX_SOCKET_DIR. Here it made a workspace look foreign to itself, so
the first shell to start the daemon locked out every other one.

Both roots are now normalized before they are compared: separators and
`.`/`..` on either platform, plus case folding on win32 only. POSIX
roots keep their case, where `/repo` and `/REPO` really can be two
directories. A genuinely foreign workspace is still rejected.

Closes #36722

<!-- Please make sure you have read the submission guidelines before
posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->

<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->

<!-- If this is a particularly complex change or feature addition, you
can request a dedicated Nx release for this pull request branch. Mention
someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they
will confirm if the PR warrants its own release for testing purposes,
and generate it for you if appropriate. -->

## Current Behavior
<!-- This is the behavior we have today -->

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #36722

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
J
Jelle Bruisten committed
28f61f46f993c7ef1f012a1f282523f6d533b306
Parent: d0dbe0e
Committed by GitHub <noreply@github.com> on 8/29/2026, 12:03:43 PM