{{ message }}
Fix clang-format/clang-tidy version check failing on Windows (and paths with spaces)#14552
Open
sean-mcmanus wants to merge 2 commits into
Open
Fix clang-format/clang-tidy version check failing on Windows (and paths with spaces)#14552sean-mcmanus wants to merge 2 commits into
sean-mcmanus wants to merge 2 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes Windows (and spaces-in-path) failures when probing clang-format/clang-tidy versions by switching from shell-based execution (execSync + quoting) to direct execution (execFileSync), ensuring the bundled LLVM binaries are correctly version-compared against system installs.
Changes:
- Replaces
execSynccommand strings withexecFileSync(..., ['--version'])for both bundled and system version probes. - Removes the
shell-quotedependency fromsettings.tssince shell quoting is no longer needed.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Fixed using Copilot with Claude Opus 4.8 in VS Code (after reproing/debugging it).
Summary: It was using the older Program Files clang-format instead of the newer bundled one.
Problem
When resolving the clang-format / clang-tidy path, the extension shells out to the bundled binary to read its version (
getClangPathinsettings.ts). On Windows this could throw:The failure happened in the bundled-binary
tryblock, silently falling through to thecatch("Unable to invoke our own clang-*") and skipping the bundled-vs-system version comparison entirely.Root cause
The bundled invocation used
shell-quote'squote()to build the command string:quote()produces POSIX-style single-quoted output ('c:\...\clang-format.exe' --version). On Windows,execSyncruns the command throughcmd.exe, which does not accept single quotes for quoting, so the command failed. The binary itself was fine — only the quoting was wrong.quote()was originally added in #11841 ("Address issues reported by compliance tooling") to stop building a shell command from an unescaped variable. So we cannot simply revert to raw string interpolation.Fix
Switch both version-probe invocations from a shell command (
execSync+ quoting) toexecFileSync, which invokes the executable directly with an argument array and no shell:Because no shell is involved:
quote()is addressed more directly — there is no shell command constructed from a variable, which is the canonical remediation for that class of finding.The
shell-quoteimport is removed since it is no longer used.What is preserved
output.match(/(\d+\.\d+\.\d+)/)?.[1]on both paths. That scenario does not regress.try/catchstructure is unchanged.getExtensionFilePath()stays inside thetry, so if the extension path is not yet initialized and it throws, the error is still caught and we fall back to the system clang-* gracefully.Testing
--versioncalls succeed on Windows where the previous single-quoted command failed.