Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve error message when using non local file URIs #11577

Open
1 task done
froli-code opened this issue Nov 5, 2022 · 0 comments
Open
1 task done

Improve error message when using non local file URIs #11577

froli-code opened this issue Nov 5, 2022 · 0 comments
Labels
C: error messages Improving error messages type: enhancement Improvements to functionality

Comments

@froli-code
Copy link
Contributor

Description

Issue created as a successor to #6247

If an URI contains a reference to a remote host (e.g. file://myfoo/ ) the following error message is provided:
ValueError: non-local file URIs are not supported on this platform: 'file://myfoo/'

Expected behavior

While the error-message is correct, it could be improved in order to explain the behavior and suggest a solution to the user.
It is quite likely that the user wanted to use a local file, and not a file located on a remote host.

The following error message is suggested:
'file://myfoo/' points to the domain 'myfoo'. Non-local file URIs are not supported on this platform. Did you mean to use 'file:/myfoo/'?

In version 22.3 the stack-trace is included in the error message as well. I don't think that this is needed, since the error message above would explain the issue.

pip version

22.3

Python version

3.10

OS

Manjaro 22.0.0

How to Reproduce

# requirements.txt
myfoo
# constraints.txt
file://myfoo/

$ pip install -r requirements.txt -c constraints.txt

Output

ERROR: Exception:
Traceback (most recent call last):
  File "/usr/lib/python3.10/site-packages/pip/_internal/cli/base_command.py", line 160, in exc_logging_wrapper
    status = run_func(*args)
  File "/usr/lib/python3.10/site-packages/pip/_internal/cli/req_command.py", line 247, in wrapper
    return func(self, options, args)
  File "/usr/lib/python3.10/site-packages/pip/_internal/commands/install.py", line 344, in run
    reqs = self.get_requirements(args, options, finder, session)
  File "/usr/lib/python3.10/site-packages/pip/_internal/cli/req_command.py", line 403, in get_requirements
    req_to_add = install_req_from_parsed_requirement(
  File "/usr/lib/python3.10/site-packages/pip/_internal/req/constructors.py", line 471, in install_req_from_parsed_requirement
    req = install_req_from_line(
  File "/usr/lib/python3.10/site-packages/pip/_internal/req/constructors.py", line 395, in install_req_from_line
    return InstallRequirement(
  File "/usr/lib/python3.10/site-packages/pip/_internal/req/req_install.py", line 127, in __init__
    self.local_file_path = self.link.file_path
  File "/usr/lib/python3.10/site-packages/pip/_internal/models/link.py", line 330, in file_path
    return url_to_path(self.url)
  File "/usr/lib/python3.10/site-packages/pip/_internal/utils/urls.py", line 43, in url_to_path
    raise ValueError(
ValueError: non-local file URIs are not supported on this platform: 'file://myfoo/'

Code of Conduct

@froli-code froli-code added S: needs triage Issues/PRs that need to be triaged type: bug A confirmed bug or unintended behavior labels Nov 5, 2022
@ichard26 ichard26 added type: enhancement Improvements to functionality C: error messages Improving error messages and removed type: bug A confirmed bug or unintended behavior S: needs triage Issues/PRs that need to be triaged labels Apr 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: error messages Improving error messages type: enhancement Improvements to functionality
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants