@@ -150,21 +150,44 @@ runs:
150150 echo "✅ GitHub CLI CodeQL extension installed successfully"
151151
152152 # On Windows, gh codeql install-stub creates a bash script which is not
153- # discoverable by Node.js child_process.spawn(). Create a .cmd wrapper
154- # so that tools using spawn('codeql', ...) can find the CodeQL CLI.
155- - name : Create Windows-compatible CodeQL CLI wrapper
153+ # discoverable by Node.js child_process.spawn() or execFile(), since
154+ # these functions only resolve real executables (.exe), not scripts.
155+ # Find the actual codeql.exe binary from the gh-codeql distribution
156+ # and add its directory to PATH so that spawn('codeql', ...) works.
157+ # This workaround can be removed once github/gh-codeql#21 is merged,
158+ # which adds native Windows support to install-stub.
159+ - name : Add CodeQL binary directory to PATH (Windows)
156160 if : runner.os == 'Windows'
157161 shell : bash
158162 run : |
159- CODEQL_STUB_DIR="$HOME/.local/bin"
163+ echo "🔧 Locating actual codeql.exe binary for Windows compatibility..."
164+
165+ # Determine the gh-codeql data directory
166+ GH_CODEQL_DIR="${LOCALAPPDATA:-$HOME/AppData/Local}/GitHub/gh-codeql"
167+
168+ if [ ! -d "$GH_CODEQL_DIR" ]; then
169+ echo "❌ Error: gh-codeql data directory not found at $GH_CODEQL_DIR"
170+ exit 1
171+ fi
172+
173+ # Find the codeql.exe binary in the gh-codeql distribution
174+ CODEQL_EXE=$(find "$GH_CODEQL_DIR" -name "codeql.exe" -type f 2>/dev/null | head -1)
175+
176+ if [ -z "$CODEQL_EXE" ]; then
177+ echo "❌ Error: codeql.exe not found in $GH_CODEQL_DIR"
178+ echo "Directory contents:"
179+ find "$GH_CODEQL_DIR" -maxdepth 3 -type f | head -20
180+ exit 1
181+ fi
182+
183+ CODEQL_BIN_DIR=$(dirname "$CODEQL_EXE")
184+ echo "Found codeql.exe at: $CODEQL_EXE"
185+ echo "Adding $CODEQL_BIN_DIR to PATH"
160186
161- cat > "$CODEQL_STUB_DIR/codeql.cmd" << 'WRAPPER'
162- @echo off
163- gh codeql %*
164- exit /b %errorlevel%
165- WRAPPER
187+ # Prepend the directory containing codeql.exe to PATH
188+ echo "$CODEQL_BIN_DIR" >> "$GITHUB_PATH"
166189
167- echo "✅ Created Windows-compatible CodeQL CLI wrapper at $CODEQL_STUB_DIR/codeql.cmd "
190+ echo "✅ Added CodeQL binary directory to PATH for Windows "
168191
169192 - name : Setup CodeQL environment variables
170193 id : setup-codeql-env
0 commit comments