@@ -54331,24 +54331,29 @@ class PipCache extends cache_distributor_1.default { |
54331 | 54331 | this.pythonVersion = pythonVersion; |
54332 | 54332 | } |
54333 | 54333 | async getCacheGlobalDirectories() { |
54334 | | - let exitCode = 1; |
| 54334 | + let exitCode = 0; |
54335 | 54335 | let stdout = ''; |
54336 | 54336 | let stderr = ''; |
54337 | 54337 | // Add temporary fix for Windows |
54338 | | - // On windows it is necessary to execute through an exec |
54339 | | - // because the getExecOutput gives a non zero code or writes to stderr for pip 22.0.2, |
| 54338 | + // On Windows, it is necessary to execute through an exec |
| 54339 | + // because the getExecOutput gives a non-zero code or writes to stderr for pip 22.0.2, |
54340 | 54340 | // or spawn must be started with the shell option enabled for getExecOutput |
54341 | 54341 | // Related issue: https://github.com/actions/setup-python/issues/328 |
54342 | 54342 | if (utils_1.IS_WINDOWS) { |
54343 | 54343 | const execPromisify = util_1.default.promisify(child_process.exec); |
54344 | | - ({ stdout: stdout, stderr: stderr } = await execPromisify('pip cache dir')); |
| 54344 | + try { |
| 54345 | + ({ stdout, stderr } = await execPromisify('pip cache dir')); |
| 54346 | + } |
| 54347 | + catch (err) { |
| 54348 | + // Pip outputs warnings to stderr (e.g., --no-python-version-warning flag deprecation warning), causing false failure detection |
| 54349 | + // Related issue: https://github.com/actions/setup-python/issues/1034 |
| 54350 | + // If an error occurs, capture stderr and set exitCode to 1 to indicate failure |
| 54351 | + stderr = err.stderr ?? err.message; |
| 54352 | + exitCode = 1; |
| 54353 | + } |
54345 | 54354 | } |
54346 | 54355 | else { |
54347 | | - ({ |
54348 | | - stdout: stdout, |
54349 | | - stderr: stderr, |
54350 | | - exitCode: exitCode |
54351 | | - } = await exec.getExecOutput('pip cache dir')); |
| 54356 | + ({ stdout, stderr, exitCode } = await exec.getExecOutput('pip cache dir')); |
54352 | 54357 | } |
54353 | 54358 | if (exitCode && stderr) { |
54354 | 54359 | throw new Error(`Could not get cache folder path for pip package manager`); |
|