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

pip mangles relative file:// URLs in contraints.txt #6247

Closed
brianthelion opened this issue Feb 8, 2019 · 6 comments
Closed

pip mangles relative file:// URLs in contraints.txt #6247

brianthelion opened this issue Feb 8, 2019 · 6 comments
Labels
C: requirement file Using `requirements.txt` type: bug A confirmed bug or unintended behavior

Comments

@brianthelion
Copy link

Environment

  • pip version: 19.0.1
  • Python version: 3.6
  • OS: Ubuntu 18.04

Description

# requirements.txt
myfoo
# constraints.txt
file://myfoo/#egg=myfoo
$ pip install -r requirements.txt -c constraints.txt
Processing ./\\myfoo
Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory: '/some/absolute/path/\\\\myfoo'
$ ls myfoo
setup.py

Note the mangling of the path string.

Expected behavior
myfoo installed successfully.

How to Reproduce
As above.

Output
As above.

@cjerdonek cjerdonek added the C: requirement file Using `requirements.txt` label Feb 8, 2019
@brianthelion
Copy link
Author

@cjerdonek This looks like it should be type: bug. The output above exhibits a pretty evident pathology. pip is trying to do the right thing, but failing due to some misplaced escapes or something.

@cjerdonek
Copy link
Member

@brianthelion You might want to take a look at PR #5892, which I believe impacts this issue. I don't know yet what behavior we want here.

@cjerdonek cjerdonek added the type: bug A confirmed bug or unintended behavior label Feb 12, 2019
@cjerdonek
Copy link
Member

Marking as a bug per @brianthelion's comment. At the least there should be a better error message.

@froli-code
Copy link
Contributor

froli-code commented Nov 4, 2022

i just reproduced this issue, and the current output is the following:

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/#egg=myfoo'

System: Manjaro 22.0.0
Python: 3.10
Pip: 22.3

I think we could close this issue, since the error message looks way better now and explains the issue.

@uranusjr
Copy link
Member

uranusjr commented Nov 5, 2022

In the original report, file://myfoo/ was supposed to mean the relative path ./myfoo/. However, that is not the correct interpretation; according to standards, this means a directory / under domain myfoo instead (as the current exception indicates).

We could possibly show an even better error message for this (which explains the above context), but that can be a separate issue. Feel free to contribute.

@froli-code
Copy link
Contributor

froli-code commented Nov 5, 2022

created #11577 as a successor to this issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 6, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
C: requirement file Using `requirements.txt` type: bug A confirmed bug or unintended behavior
Projects
None yet
Development

No branches or pull requests

4 participants