Skip to content

Commit 89283fe

Browse files
CI Botclaude
andcommitted
fix: add diagnostic logging for Windows Python discovery in CI
Added diagnostic logging to understand why Python discovery fails in GitHub Actions Windows environment while working on local Windows. The logging only activates when CI=true or DEBUG_PYTHON_DISCOVERY is set. This will help diagnose: - PATH environment variable case sensitivity issues - Which commands are being tried and why they fail - Whether the Path to PATH copy is happening Keeping the simple PATH fix that handles Windows case-insensitive environment variables in Node.js. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 71cf7e6 commit 89283fe

1 file changed

Lines changed: 23 additions & 4 deletions

File tree

‎packages/adapter-python/src/utils/python-utils.ts‎

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,32 @@ class WhichCommandFinder implements CommandFinder {
4242
try {
4343
// Fix for Windows: which library fails if PATH is undefined but Path exists
4444
// Windows env vars are case-insensitive, but Node.js treats them as case-sensitive
45-
// GitHub Actions on Windows may have Path but not PATH
46-
if (process.platform === 'win32' && !process.env.PATH && process.env.Path) {
47-
process.env.PATH = process.env.Path;
45+
if (process.platform === 'win32') {
46+
// Diagnostic logging in CI to understand the issue
47+
if (process.env.CI === 'true' || process.env.DEBUG_PYTHON_DISCOVERY) {
48+
console.error(`[Python Discovery] Looking for command: ${cmd}`);
49+
console.error(`[Python Discovery] Environment:`, {
50+
CI: process.env.CI,
51+
GITHUB_ACTIONS: process.env.GITHUB_ACTIONS,
52+
PATH: process.env.PATH ? `defined (${process.env.PATH.split(';').length} entries)` : 'undefined',
53+
Path: process.env.Path ? `defined (${process.env.Path?.split(';').length} entries)` : 'undefined',
54+
});
55+
}
56+
57+
if (!process.env.PATH && process.env.Path) {
58+
process.env.PATH = process.env.Path;
59+
if (process.env.CI === 'true') {
60+
console.error(`[Python Discovery] Copied Path to PATH`);
61+
}
62+
}
4863
}
4964
const resolved = await which(cmd);
5065
if (this.useCache) this.cache.set(cmd, resolved);
5166
return resolved;
52-
} catch {
67+
} catch (error) {
68+
if (process.env.CI === 'true' || process.env.DEBUG_PYTHON_DISCOVERY) {
69+
console.error(`[Python Discovery] Failed to find ${cmd}:`, (error as Error).message);
70+
}
5371
throw new CommandNotFoundError(cmd);
5472
}
5573
}
@@ -199,6 +217,7 @@ export async function findPythonExecutable(
199217
}
200218
}
201219

220+
202221
// 4. Check each valid Python for debugpy and return the first one that has it
203222
logger.debug?.(`[Python Detection] Checking ${validPythonPaths.length} Python installations for debugpy...`);
204223
for (const pythonPath of validPythonPaths) {

0 commit comments

Comments
 (0)