From 12b7ec143f8731977a9d683b9247df538bc14426 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 29 Jan 2026 19:45:40 +0000 Subject: [PATCH 1/3] Initial plan From c48b8b94eb481c65a118dfc2965dcb3d6f82dd1e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 29 Jan 2026 20:19:05 +0000 Subject: [PATCH 2/3] Add Cygwin/MSYS path conversion for build tasks Co-authored-by: snehara99 <113148726+snehara99@users.noreply.github.com> --- src/make.ts | 24 +++++++++++++++++-- src/util.ts | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+), 2 deletions(-) diff --git a/src/make.ts b/src/make.ts index 308bafa3..31af7bf7 100644 --- a/src/make.ts +++ b/src/make.ts @@ -456,8 +456,28 @@ export async function doBuildTarget( try { const quotingStlye: vscode.ShellQuoting = vscode.ShellQuoting.Strong; const quotingStyleName: string = "Strong"; + + // Check if the terminal is using Cygwin/MSYS bash and convert paths accordingly + const usingCygwinBash = util.isWindowsTerminalUsingCygwinOrMsysBash(); + let commandValue = configuration.getConfigurationMakeCommand(); + let cwdValue: string = configuration.makeBaseDirectory(); + + if (usingCygwinBash) { + // Convert Windows paths to POSIX paths for Cygwin/MSYS bash compatibility + commandValue = util.windowsPathToPosix(commandValue); + cwdValue = util.windowsPathToPosix(cwdValue); + // Convert any path arguments (like -f makefile path) + makeArgs = makeArgs.map((arg) => { + // Check if the argument looks like a Windows absolute path + if (/^[A-Za-z]:[\\\/]/.test(arg)) { + return util.windowsPathToPosix(arg); + } + return arg; + }); + } + let myTaskCommand: vscode.ShellQuotedString = { - value: configuration.getConfigurationMakeCommand(), + value: commandValue, quoting: quotingStlye, }; let myTaskArgs: vscode.ShellQuotedString[] = makeArgs.map((arg) => { @@ -485,7 +505,7 @@ export async function doBuildTarget( util.modifiedEnvironmentVariables as util.EnvironmentVariables ) : undefined, - cwd, + cwd: cwdValue, }; let shellExec: vscode.ShellExecution = new vscode.ShellExecution( diff --git a/src/util.ts b/src/util.ts index fa362979..7d1dbfe5 100644 --- a/src/util.ts +++ b/src/util.ts @@ -597,6 +597,72 @@ export async function ensureWindowsPath(path: string): Promise { return winPath; } +// Check if the default terminal shell on Windows is a Cygwin/MSYS bash. +// This is determined by looking at the terminal.integrated.defaultProfile.windows setting +// and checking if the corresponding profile uses a bash.exe from cygwin or msys paths. +export function isWindowsTerminalUsingCygwinOrMsysBash(): boolean { + if (process.platform !== "win32") { + return false; + } + + const terminalConfig = vscode.workspace.getConfiguration("terminal"); + const defaultProfileName = terminalConfig.get( + "integrated.defaultProfile.windows" + ); + + if (!defaultProfileName) { + return false; + } + + const profiles = terminalConfig.get>( + "integrated.profiles.windows" + ); + + if (!profiles) { + return false; + } + + const profile = profiles[defaultProfileName]; + if (!profile || !profile.path) { + return false; + } + + const shellPath = profile.path.toLowerCase(); + // Check if the shell is a bash from cygwin or msys paths + return ( + (shellPath.includes("cygwin") || shellPath.includes("msys")) && + shellPath.endsWith("bash.exe") + ); +} + +// Convert a Windows path (C:\path\to\file) into a POSIX path for use with Cygwin/MSYS bash. +// This is the inverse of ensureWindowsPath. +// Example: C:\cygwin64\bin\make.exe -> /cygdrive/c/cygwin64/bin/make.exe +export function windowsPathToPosix(windowsPath: string): string { + if (!windowsPath) { + return windowsPath; + } + + // Check if it's already a POSIX path + if (windowsPath.startsWith("/")) { + return windowsPath; + } + + // Check if it's a Windows absolute path (e.g., C:\path or C:/path) + const windowsAbsolutePathRegex = /^([A-Za-z]):[\\\/]/; + const match = windowsPath.match(windowsAbsolutePathRegex); + + if (match) { + const driveLetter = match[1].toLowerCase(); + // Remove the drive letter and colon, replace backslashes with forward slashes + const restOfPath = windowsPath.substring(2).replace(/\\/g, "/"); + return `/cygdrive/${driveLetter}${restOfPath}`; + } + + // For relative paths or paths without a drive letter, just replace backslashes + return windowsPath.replace(/\\/g, "/"); +} + // Helper to reinterpret one relative path (to the given current path) printed by make as full path export async function makeFullPath( relPath: string, From 3390b0c9e723e3280b1bdd795a8cb7c316796c60 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 29 Jan 2026 20:39:27 +0000 Subject: [PATCH 3/3] Add unit tests for windowsPathToPosix function Co-authored-by: snehara99 <113148726+snehara99@users.noreply.github.com> --- src/test/fakeSuite/extension.test.ts | 65 ++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/src/test/fakeSuite/extension.test.ts b/src/test/fakeSuite/extension.test.ts index 5dfcb038..d94bddd0 100644 --- a/src/test/fakeSuite/extension.test.ts +++ b/src/test/fakeSuite/extension.test.ts @@ -130,6 +130,71 @@ suite("Unit testing replacing characters in and outside of quotes", () => { }); }); +suite("Unit testing Windows to POSIX path conversion", () => { + suiteSetup(async function (this: Mocha.Context) { + this.timeout(100000); + }); + + setup(async function (this: Mocha.Context) { + this.timeout(100000); + }); + + test("Test windowsPathToPosix with absolute Windows paths", () => { + const tests = [ + "C:\\cygwin64\\bin\\make.exe", + "D:\\projects\\myapp\\Makefile", + "c:\\Users\\user\\git\\project", + "E:/path/with/forward/slashes", + ]; + const expectedResults = [ + "/cygdrive/c/cygwin64/bin/make.exe", + "/cygdrive/d/projects/myapp/Makefile", + "/cygdrive/c/Users/user/git/project", + "/cygdrive/e/path/with/forward/slashes", + ]; + + for (let i = 0; i < tests.length; i++) { + expect(util.windowsPathToPosix(tests[i])).to.be.equal(expectedResults[i]); + } + }); + + test("Test windowsPathToPosix with already POSIX paths", () => { + const tests = [ + "/usr/bin/make", + "/cygdrive/c/path/to/file", + "/home/user/project", + ]; + // POSIX paths should be returned unchanged + for (let i = 0; i < tests.length; i++) { + expect(util.windowsPathToPosix(tests[i])).to.be.equal(tests[i]); + } + }); + + test("Test windowsPathToPosix with relative paths", () => { + const tests = [ + "relative\\path\\to\\file", + "..\\parent\\dir", + ".\\current\\dir", + "just-a-filename.txt", + ]; + const expectedResults = [ + "relative/path/to/file", + "../parent/dir", + "./current/dir", + "just-a-filename.txt", + ]; + + for (let i = 0; i < tests.length; i++) { + expect(util.windowsPathToPosix(tests[i])).to.be.equal(expectedResults[i]); + } + }); + + test("Test windowsPathToPosix with empty and special cases", () => { + expect(util.windowsPathToPosix("")).to.be.equal(""); + expect(util.windowsPathToPosix("make")).to.be.equal("make"); + }); +}); + // TODO: refactor initialization and cleanup of each test suite("Fake dryrun parsing", () => { suiteSetup(async function (this: Mocha.Context) {