From 9cbe7f60adaaaa9d060a6165a57098a526ad7f82 Mon Sep 17 00:00:00 2001 From: OBITORASU Date: Tue, 8 Jun 2021 21:09:09 +0530 Subject: [PATCH 01/14] Warning for user when Windows path limit is exceeded --- src/pip/_internal/commands/install.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/pip/_internal/commands/install.py b/src/pip/_internal/commands/install.py index 6932f5a6d8b..a35ac06ae0a 100644 --- a/src/pip/_internal/commands/install.py +++ b/src/pip/_internal/commands/install.py @@ -26,6 +26,7 @@ from pip._internal.req import install_given_reqs from pip._internal.req.req_install import InstallRequirement from pip._internal.req.req_tracker import get_requirement_tracker +from pip._internal.utils.compat import WINDOWS from pip._internal.utils.distutils_args import parse_distutils_args from pip._internal.utils.filesystem import test_writable_dir from pip._internal.utils.misc import ( @@ -440,6 +441,13 @@ def run(self, options, args): message = create_os_error_message( error, show_traceback, options.use_user_site, ) + if WINDOWS and len(message) >= 280: + logger.warning( + 'The following error can potentially be caused ' + 'because Long Paths is disabled on your system. ' + 'Please set LongPathsEnabled to 1 in the ' + 'registry and try again.' + ) logger.error(message, exc_info=show_traceback) # noqa return ERROR From 7204b9240db717ec60b67bef946c446b37db59a0 Mon Sep 17 00:00:00 2001 From: OBITORASU Date: Tue, 8 Jun 2021 21:17:21 +0530 Subject: [PATCH 02/14] add news entry for issue 10045 --- news/10045.feature.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 news/10045.feature.rst diff --git a/news/10045.feature.rst b/news/10045.feature.rst new file mode 100644 index 00000000000..201f66bf7fb --- /dev/null +++ b/news/10045.feature.rst @@ -0,0 +1 @@ +Added a warning message for errors caused due to Long Paths being disabled on Windows. \ No newline at end of file From 5c735941532a224b9cac4c8d3d36b7f3c367ab7f Mon Sep 17 00:00:00 2001 From: OBITORASU Date: Tue, 8 Jun 2021 21:40:45 +0530 Subject: [PATCH 03/14] change message to error --- src/pip/_internal/commands/install.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pip/_internal/commands/install.py b/src/pip/_internal/commands/install.py index a35ac06ae0a..aeed0f3cda3 100644 --- a/src/pip/_internal/commands/install.py +++ b/src/pip/_internal/commands/install.py @@ -441,7 +441,7 @@ def run(self, options, args): message = create_os_error_message( error, show_traceback, options.use_user_site, ) - if WINDOWS and len(message) >= 280: + if WINDOWS and len(error) >= 280: logger.warning( 'The following error can potentially be caused ' 'because Long Paths is disabled on your system. ' From e22799bd8e409bdab09d62f9baaed2fb0caa6aea Mon Sep 17 00:00:00 2001 From: OBITORASU Date: Tue, 8 Jun 2021 21:57:16 +0530 Subject: [PATCH 04/14] update padding around default limit --- src/pip/_internal/commands/install.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pip/_internal/commands/install.py b/src/pip/_internal/commands/install.py index aeed0f3cda3..58f47f0b8dc 100644 --- a/src/pip/_internal/commands/install.py +++ b/src/pip/_internal/commands/install.py @@ -441,7 +441,7 @@ def run(self, options, args): message = create_os_error_message( error, show_traceback, options.use_user_site, ) - if WINDOWS and len(error) >= 280: + if WINDOWS and len(error) >= 270: logger.warning( 'The following error can potentially be caused ' 'because Long Paths is disabled on your system. ' From fe4ab16d3f56039ba345bf815da6408ea0776911 Mon Sep 17 00:00:00 2001 From: OBITORASU Date: Tue, 8 Jun 2021 22:30:47 +0530 Subject: [PATCH 05/14] add reference link and extra checks --- src/pip/_internal/commands/install.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/pip/_internal/commands/install.py b/src/pip/_internal/commands/install.py index 58f47f0b8dc..65412075940 100644 --- a/src/pip/_internal/commands/install.py +++ b/src/pip/_internal/commands/install.py @@ -441,13 +441,18 @@ def run(self, options, args): message = create_os_error_message( error, show_traceback, options.use_user_site, ) - if WINDOWS and len(error) >= 270: - logger.warning( - 'The following error can potentially be caused ' - 'because Long Paths is disabled on your system. ' - 'Please set LongPathsEnabled to 1 in the ' - 'registry and try again.' - ) + if WINDOWS and len(str(error)) >= 270: + if error.errno == errno.ENOENT: + logger.warning( + 'The following error can potentially be caused ' + 'because Long Paths is disabled on your system. ' + 'Please set LongPathsEnabled to 1 in the ' + 'registry and try again. For further instructions ' + 'please refer to the documentation: https://docs.' + 'microsoft.com/en-us/windows/win32/fileio/maximum' + '-file-path-limitation?tabs=cmd#enable-long-paths' + '-in-windows-10-version-1607-and-later' + ) logger.error(message, exc_info=show_traceback) # noqa return ERROR From 4dbf953ba25a9ea438a4947fc410892a1e16cd46 Mon Sep 17 00:00:00 2001 From: OBITORASU Date: Tue, 8 Jun 2021 22:31:08 +0530 Subject: [PATCH 06/14] fix lint issue in docs --- news/10045.feature.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/news/10045.feature.rst b/news/10045.feature.rst index 201f66bf7fb..7c7b53725fc 100644 --- a/news/10045.feature.rst +++ b/news/10045.feature.rst @@ -1 +1 @@ -Added a warning message for errors caused due to Long Paths being disabled on Windows. \ No newline at end of file +Added a warning message for errors caused due to Long Paths being disabled on Windows. From 5e2c0cc8f77ac5af3d7d4bb0d71b6fe0a66c7d46 Mon Sep 17 00:00:00 2001 From: OBITORASU Date: Wed, 9 Jun 2021 00:30:29 +0530 Subject: [PATCH 07/14] add check to verify error.filename is not none --- src/pip/_internal/commands/install.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/pip/_internal/commands/install.py b/src/pip/_internal/commands/install.py index 65412075940..203a1de27d5 100644 --- a/src/pip/_internal/commands/install.py +++ b/src/pip/_internal/commands/install.py @@ -441,18 +441,18 @@ def run(self, options, args): message = create_os_error_message( error, show_traceback, options.use_user_site, ) - if WINDOWS and len(str(error)) >= 270: - if error.errno == errno.ENOENT: - logger.warning( - 'The following error can potentially be caused ' - 'because Long Paths is disabled on your system. ' - 'Please set LongPathsEnabled to 1 in the ' - 'registry and try again. For further instructions ' - 'please refer to the documentation: https://docs.' - 'microsoft.com/en-us/windows/win32/fileio/maximum' - '-file-path-limitation?tabs=cmd#enable-long-paths' - '-in-windows-10-version-1607-and-later' - ) + if (WINDOWS and error.errno == errno.ENOENT and error.filename and + len(str(error)) >= 270): + logger.warning( + 'The following error can potentially be caused ' + 'because Long Paths is disabled on your system. ' + 'Please set LongPathsEnabled to 1 in the ' + 'registry and try again. For further instructions ' + 'please refer to the documentation: https://docs.' + 'microsoft.com/en-us/windows/win32/fileio/maximum' + '-file-path-limitation?tabs=cmd#enable-long-paths' + '-in-windows-10-version-1607-and-later' + ) logger.error(message, exc_info=show_traceback) # noqa return ERROR From 45930078a65a53f762705aab5bbf92e663a73a8d Mon Sep 17 00:00:00 2001 From: OBITORASU Date: Wed, 9 Jun 2021 00:33:23 +0530 Subject: [PATCH 08/14] use error.filename instead of error --- src/pip/_internal/commands/install.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pip/_internal/commands/install.py b/src/pip/_internal/commands/install.py index 203a1de27d5..54576dabe69 100644 --- a/src/pip/_internal/commands/install.py +++ b/src/pip/_internal/commands/install.py @@ -442,7 +442,7 @@ def run(self, options, args): error, show_traceback, options.use_user_site, ) if (WINDOWS and error.errno == errno.ENOENT and error.filename and - len(str(error)) >= 270): + len(error.filename) >= 260): logger.warning( 'The following error can potentially be caused ' 'because Long Paths is disabled on your system. ' From 67dcdf5e110a430e2a544061726f16971d122ba4 Mon Sep 17 00:00:00 2001 From: OBITORASU Date: Wed, 9 Jun 2021 00:53:17 +0530 Subject: [PATCH 09/14] use error.filename, remove padding and shorten url --- src/pip/_internal/commands/install.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/pip/_internal/commands/install.py b/src/pip/_internal/commands/install.py index 54576dabe69..8ccee9f345f 100644 --- a/src/pip/_internal/commands/install.py +++ b/src/pip/_internal/commands/install.py @@ -442,16 +442,14 @@ def run(self, options, args): error, show_traceback, options.use_user_site, ) if (WINDOWS and error.errno == errno.ENOENT and error.filename and - len(error.filename) >= 260): + len(error.filename) > 260): logger.warning( 'The following error can potentially be caused ' 'because Long Paths is disabled on your system. ' 'Please set LongPathsEnabled to 1 in the ' 'registry and try again. For further instructions ' - 'please refer to the documentation: https://docs.' - 'microsoft.com/en-us/windows/win32/fileio/maximum' - '-file-path-limitation?tabs=cmd#enable-long-paths' - '-in-windows-10-version-1607-and-later' + 'please refer to the documentation: ' + 'https://pip.pypa.io/warnings/enable-long-paths' ) logger.error(message, exc_info=show_traceback) # noqa From 560d2e97ae9bc51a94d8a3c81f6ee3718d7a202f Mon Sep 17 00:00:00 2001 From: OBITORASU Date: Wed, 9 Jun 2021 01:05:54 +0530 Subject: [PATCH 10/14] move the check to create_os_error_message --- src/pip/_internal/commands/install.py | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/pip/_internal/commands/install.py b/src/pip/_internal/commands/install.py index 8ccee9f345f..808bb5a1c49 100644 --- a/src/pip/_internal/commands/install.py +++ b/src/pip/_internal/commands/install.py @@ -441,16 +441,6 @@ def run(self, options, args): message = create_os_error_message( error, show_traceback, options.use_user_site, ) - if (WINDOWS and error.errno == errno.ENOENT and error.filename and - len(error.filename) > 260): - logger.warning( - 'The following error can potentially be caused ' - 'because Long Paths is disabled on your system. ' - 'Please set LongPathsEnabled to 1 in the ' - 'registry and try again. For further instructions ' - 'please refer to the documentation: ' - 'https://pip.pypa.io/warnings/enable-long-paths' - ) logger.error(message, exc_info=show_traceback) # noqa return ERROR @@ -748,4 +738,17 @@ def create_os_error_message(error, show_traceback, using_user_site): parts.append(permissions_part) parts.append(".\n") + # Suggest the user to enable Long Paths if path length is + # more than 260 + if (WINDOWS and error.errno == errno.ENOENT and error.filename and + len(error.filename) > 260): + parts.append( + "The following error can potentially be caused " + "because Long Paths is disabled on your system. " + "Please set LongPathsEnabled to 1 in the " + "registry and try again. For further instructions " + "please refer to the documentation: " + "https://pip.pypa.io/warnings/enable-long-paths" + ) + return "".join(parts).strip() + "\n" From 1458166a28a30c77d04bcc8ffc05396afc03f715 Mon Sep 17 00:00:00 2001 From: OBITORASU Date: Wed, 9 Jun 2021 01:10:01 +0530 Subject: [PATCH 11/14] fix the wordings --- src/pip/_internal/commands/install.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pip/_internal/commands/install.py b/src/pip/_internal/commands/install.py index 808bb5a1c49..ba157f1f87c 100644 --- a/src/pip/_internal/commands/install.py +++ b/src/pip/_internal/commands/install.py @@ -743,7 +743,7 @@ def create_os_error_message(error, show_traceback, using_user_site): if (WINDOWS and error.errno == errno.ENOENT and error.filename and len(error.filename) > 260): parts.append( - "The following error can potentially be caused " + "This error can potentially be caused " "because Long Paths is disabled on your system. " "Please set LongPathsEnabled to 1 in the " "registry and try again. For further instructions " From 9ba78c964e6aa61fafd530743fdfba08ae88f754 Mon Sep 17 00:00:00 2001 From: OBITORASU Date: Wed, 9 Jun 2021 11:19:46 +0530 Subject: [PATCH 12/14] change wordings for the info message --- src/pip/_internal/commands/install.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pip/_internal/commands/install.py b/src/pip/_internal/commands/install.py index ba157f1f87c..03286ab26a1 100644 --- a/src/pip/_internal/commands/install.py +++ b/src/pip/_internal/commands/install.py @@ -743,8 +743,8 @@ def create_os_error_message(error, show_traceback, using_user_site): if (WINDOWS and error.errno == errno.ENOENT and error.filename and len(error.filename) > 260): parts.append( - "This error can potentially be caused " - "because Long Paths is disabled on your system. " + "A potential cause to this error is " + "Long Paths beign disabled on your system. " "Please set LongPathsEnabled to 1 in the " "registry and try again. For further instructions " "please refer to the documentation: " From 9f0338a416f07d8a8b7d98bbf47c815c29452a9e Mon Sep 17 00:00:00 2001 From: OBITORASU Date: Fri, 11 Jun 2021 10:49:48 +0530 Subject: [PATCH 13/14] fix typo --- src/pip/_internal/commands/install.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pip/_internal/commands/install.py b/src/pip/_internal/commands/install.py index 03286ab26a1..b4fbcc305af 100644 --- a/src/pip/_internal/commands/install.py +++ b/src/pip/_internal/commands/install.py @@ -744,7 +744,7 @@ def create_os_error_message(error, show_traceback, using_user_site): len(error.filename) > 260): parts.append( "A potential cause to this error is " - "Long Paths beign disabled on your system. " + "Long Paths being disabled on your system. " "Please set LongPathsEnabled to 1 in the " "registry and try again. For further instructions " "please refer to the documentation: " From 7a64c944b8c895db68fa40842694f429c934377f Mon Sep 17 00:00:00 2001 From: OBITORASU Date: Fri, 11 Jun 2021 15:13:53 +0530 Subject: [PATCH 14/14] minor rephrasing of message --- src/pip/_internal/commands/install.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/pip/_internal/commands/install.py b/src/pip/_internal/commands/install.py index b4fbcc305af..2fa6a62740a 100644 --- a/src/pip/_internal/commands/install.py +++ b/src/pip/_internal/commands/install.py @@ -743,12 +743,11 @@ def create_os_error_message(error, show_traceback, using_user_site): if (WINDOWS and error.errno == errno.ENOENT and error.filename and len(error.filename) > 260): parts.append( - "A potential cause to this error is " - "Long Paths being disabled on your system. " - "Please set LongPathsEnabled to 1 in the " - "registry and try again. For further instructions " - "please refer to the documentation: " - "https://pip.pypa.io/warnings/enable-long-paths" + "HINT: This error might have occurred since " + "this system does not have Windows Long Path " + "support enabled. You can find information on " + "how to enable this at " + "https://pip.pypa.io/warnings/enable-long-paths\n" ) return "".join(parts).strip() + "\n"