Skip to content

The git+file requirement format doesn't seem to work the way documentation says it does #12124

@jparta

Description

@jparta

Description

I'm trying to include a dependency in my requirements.txt file which would get my local git repository. I'm using the package @ git+file:// format, as shown here:
https://pip.pypa.io/en/stable/topics/vcs-support/
The git documentation shows the same file:// format: https://git-scm.com/docs/git-clone#_git_urls

But when I use the format

my_package @ git+file:///home/path_to_package/my_package/

I get the following error:

ERROR: Invalid requirement: 'my_package @ git+file:///home/path_to_package/my_package/' (from line 1 of requirements.txt)
Hint: It looks like a path. File 'my_package @ git+file:///home/path_to_package/my_package/' does not exist.

I can get it to install if I use the following format:

my_package @ git+file://dummy_host/home/path_to_package/my_package/
It seems that the host element of the file URI scheme is required, which is not what the documentation says.

Expected behavior

That the git+file URI scheme works as explained in these documents:
https://pip.pypa.io/en/stable/topics/vcs-support/
https://git-scm.com/docs/git-clone#_git_urls

I.e. my_package @ git+file:///home/path_to_package/my_package/

in requirements.txt and running pip install -r requirements.txt installs my_package without errors.

pip version

pip 23.1.2

Python version

Python 3.11.3

OS

Ubuntu 20.04.6 LTS

How to Reproduce

  1. Have a local python package as a git repo in /home/path_to_package/my_package/
  2. Make a pip-based virtual environment and activate it
  3. echo "my_package @ git+file:///home/path_to_package/my_package/" > requirements.txt
  4. pip install -r requirements.txt

Output

11:05 $ pip install -r requirements.txt 
    ERROR: Invalid requirement: 'my_package @ git+file:///home/path_to_package/my_package/' (from line 2 of requirements.txt)
    Hint: It looks like a path. File 'my_package @ git+file:///home/path_to_package/my_package/' does not exist.

Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions