Skip to content

fix(@angular/build): canonicalize drive letter casing for workspace root on Windows#33567

Open
clydin wants to merge 1 commit into
angular:mainfrom
clydin:fix-vitest-casing-windows
Open

fix(@angular/build): canonicalize drive letter casing for workspace root on Windows#33567
clydin wants to merge 1 commit into
angular:mainfrom
clydin:fix-vitest-casing-windows

Conversation

@clydin

@clydin clydin commented Jul 14, 2026

Copy link
Copy Markdown
Member

On Windows, process.cwd() casing can inherit the casing from the shell where the command was executed (e.g. lowercase c:\projects\my-app). When running builds or unit tests, the builders pass this workspaceRoot to underlying tools.

Since Node's ESM loader and other tools resolve real file paths using canonical on-disk casing (which has an uppercase drive letter, C:\projects\my-app), the casing mismatches cause duplicate module imports (such as loading the vitest package twice) or path lookup mismatches.

This introduces a shared canonicalizePath helper in utils/path.ts which normalizes the drive-letter casing of the workspace root to uppercase on Windows, and resolves symbolic links unless preserveSymlinks is enabled. It refactors the application and unit-test builders to use this shared helper.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors path normalization across Angular builders by introducing a central canonicalizePath utility function that handles Windows drive-letter casing and symbolic link resolution. This utility is integrated into both the application and unit-test builders to ensure consistent workspace root resolution. A review comment correctly identifies that on Windows, calling realpathSync after drive-letter normalization can overwrite the uppercase casing, and suggests applying the normalization to the final resolved path instead.

Comment thread packages/angular/build/src/utils/path.ts
…oot on Windows

On Windows, process.cwd() casing can inherit the casing from the shell where the command was executed (e.g. lowercase c:\projects\my-app). When running builds or unit tests, the builders pass this workspaceRoot to underlying tools.

Since Node's ESM loader and other tools resolve real file paths using canonical on-disk casing (which has an uppercase drive letter, C:\projects\my-app), the casing mismatches cause duplicate module imports (such as loading the vitest package twice) or path lookup mismatches.

This introduces a shared canonicalizePath helper in utils/path.ts which normalizes the drive-letter casing of the workspace root to uppercase on Windows, and resolves symbolic links unless preserveSymlinks is enabled. It refactors the application and unit-test builders to use this shared helper.
@clydin clydin force-pushed the fix-vitest-casing-windows branch from d60c883 to a51a11b Compare July 14, 2026 20:12
@clydin clydin added the target: patch This PR is targeted for the next patch release label Jul 14, 2026
@clydin clydin added the action: review The PR is still awaiting reviews from at least one requested reviewer label Jul 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: review The PR is still awaiting reviews from at least one requested reviewer area: @angular/build target: patch This PR is targeted for the next patch release

Projects

None yet

1 participant