Skip to content

Commit 5672421

Browse files
authored
Suggest checking "pip config debug" in case of InvalidProxyURL error (#12690)
1 parent f2cdcd0 commit 5672421

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

news/12649.feature.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Suggest checking "pip config debug" in case of an InvalidProxyURL error.

src/pip/_internal/commands/install.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from typing import List, Optional
99

1010
from pip._vendor.packaging.utils import canonicalize_name
11+
from pip._vendor.requests.exceptions import InvalidProxyURL
1112
from pip._vendor.rich import print_json
1213

1314
# Eagerly import self_outdated_check to avoid crashes. Otherwise,
@@ -766,6 +767,13 @@ def create_os_error_message(
766767
parts.append(permissions_part)
767768
parts.append(".\n")
768769

770+
# Suggest to check "pip config debug" in case of invalid proxy
771+
if type(error) is InvalidProxyURL:
772+
parts.append(
773+
'Consider checking your local proxy configuration with "pip config debug"'
774+
)
775+
parts.append(".\n")
776+
769777
# Suggest the user to enable Long Paths if path length is
770778
# more than 260
771779
if (

tests/unit/test_command_install.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
import pytest
55

6+
from pip._vendor.requests.exceptions import InvalidProxyURL
7+
68
from pip._internal.commands import install
79
from pip._internal.commands.install import create_os_error_message, decide_user_install
810

@@ -108,6 +110,16 @@ def test_most_cases(
108110
" file permission\nConsider using the `--user` option or check the"
109111
" permissions.\n",
110112
),
113+
# Testing custom InvalidProxyURL with help message
114+
# show_traceback = True, using_user_site = True
115+
(
116+
InvalidProxyURL(),
117+
True,
118+
True,
119+
"Could not install packages due to an OSError.\n"
120+
"Consider checking your local proxy configuration"
121+
' with "pip config debug".\n',
122+
),
111123
],
112124
)
113125
def test_create_os_error_message(

0 commit comments

Comments
 (0)