diff --git a/.github/actions/setup-codeql-environment/action.yml b/.github/actions/setup-codeql-environment/action.yml index 7918eb0b..4a15128d 100644 --- a/.github/actions/setup-codeql-environment/action.yml +++ b/.github/actions/setup-codeql-environment/action.yml @@ -149,6 +149,23 @@ runs: echo "✅ GitHub CLI CodeQL extension installed successfully" + # On Windows, gh codeql install-stub creates a bash script which is not + # discoverable by Node.js child_process.spawn(). Create a .cmd wrapper + # so that tools using spawn('codeql', ...) can find the CodeQL CLI. + - name: Create Windows-compatible CodeQL CLI wrapper + if: runner.os == 'Windows' + shell: bash + run: | + CODEQL_STUB_DIR="$HOME/.local/bin" + + cat > "$CODEQL_STUB_DIR/codeql.cmd" << 'WRAPPER' + @echo off + gh codeql %* + exit /b %errorlevel% + WRAPPER + + echo "✅ Created Windows-compatible CodeQL CLI wrapper at $CODEQL_STUB_DIR/codeql.cmd" + - name: Setup CodeQL environment variables id: setup-codeql-env shell: bash diff --git a/client/src/ql-mcp-client.js b/client/src/ql-mcp-client.js index 19cb0c24..0faada09 100755 --- a/client/src/ql-mcp-client.js +++ b/client/src/ql-mcp-client.js @@ -87,10 +87,12 @@ class CodeQLMCPClient { this.logger.log("Checking for CodeQL CLI availability..."); // Try to run 'codeql version' to check if it's available + // On Windows, explicitly use bash since the CodeQL stub is a bash script const version = execSync("codeql version", { encoding: "utf8", stdio: ["pipe", "pipe", "pipe"], - timeout: 5000 + timeout: 5000, + shell: process.platform === "win32" ? "bash" : undefined }).trim(); this.logger.log(`Found CodeQL CLI: ${version.split("\n")[0]}`);