@@ -54331,24 +54331,29 @@ class PipCache extends cache_distributor_1.default {
5433154331 this.pythonVersion = pythonVersion;
5433254332 }
5433354333 async getCacheGlobalDirectories() {
54334- let exitCode = 1 ;
54334+ let exitCode = 0 ;
5433554335 let stdout = '';
5433654336 let stderr = '';
5433754337 // 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,
5434054340 // or spawn must be started with the shell option enabled for getExecOutput
5434154341 // Related issue: https://github.com/actions/setup-python/issues/328
5434254342 if (utils_1.IS_WINDOWS) {
5434354343 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+ }
5434554354 }
5434654355 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'));
5435254357 }
5435354358 if (exitCode && stderr) {
5435454359 throw new Error(`Could not get cache folder path for pip package manager`);
0 commit comments