Skip to content

Commit b6be01a

Browse files
committed
Catch errors from running the subprocess
1 parent b5afdd6 commit b6be01a

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/pip/_internal/cli/main_parser.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,13 @@ def parse_command(args: List[str]) -> Tuple[str, List[str]]:
120120
# Set a flag so the child doesn't re-invoke itself, causing
121121
# an infinite loop.
122122
os.environ["_PIP_RUNNING_IN_SUBPROCESS"] = "1"
123-
proc = subprocess.run(pip_cmd)
124-
sys.exit(proc.returncode)
123+
returncode = 0
124+
try:
125+
proc = subprocess.run(pip_cmd)
126+
returncode = proc.returncode
127+
except (subprocess.SubprocessError, OSError) as exc:
128+
raise CommandError(f"Failed to run pip under {interpreter}: {exc}")
129+
sys.exit(returncode)
125130

126131
# --version
127132
if general_options.version:

0 commit comments

Comments
 (0)