pip: Cannot install top-level git repo over SSH

pip version

21.0.1

Python version

3.9.1

OS

linux

Additional information

No response

Description

I have an SSH server, say git.myserver.com, which hosts the git repos for some of my personal projects. In the past I could just:

$ pip install -e git+git@git.myserver.com:myproject.git#egg=myproject

Attempting to do this using the new format does not seem to be supported:

$ pip install -e git+git@git.myserver.com/myproject.git#egg=myproject
  Cloning ssh://****@git.myserver.com/myproject.git to ./src/myproject
  Running command git clone -q 'ssh://****@git.myserver.com/myproject.git' /home/.../myproject
  fatal: '/myproject.git' does not appear to be a git repository
  fatal: Could not read from remote repository.

  Please make sure you have the correct access rights
  and the repository exists.

Expected behavior

To be able to install packages that are at the top-level of my git/ssh server.

How to Reproduce

  1. Put a package at the root of a server you can access via SSH
  2. Attempt to install over SSH with pip
  3. An error occurs - it seems like pip is trying to read “/myproject.git” when it should be using “myproject.git”

Output

  Cloning ssh://****@git.myserver.com/myproject.git to ./src/myproject
  Running command git clone -q 'ssh://****@git.myserver.com/myproject.git' /home/.../myproject
  fatal: '/myproject.git' does not appear to be a git repository
  fatal: Could not read from remote repository.

  Please make sure you have the correct access rights
  and the repository exists.

Code of Conduct

  • I agree to follow the PSF Code of Conduct

Please advise on how to resolve this issue. It is preventing installing privately-managed packages.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 1
  • Comments: 23 (8 by maintainers)

Most upvoted comments

Here is what I get:

ssh://****@git.myserver.com/myapp.git to ./src/myapp
Running command git clone -q 'ssh://****@git.myserver.com/myapp.git' /home/.../src/myapp
  fatal: '/myapp.git' does not appear to be a git repository
  fatal: Could not read from remote repository.

What I expect is that pip does not interpret the repo name as an absolute path. Previously I would use a colon to indicate the remote repo I was installed, e.g. (old version):

git@git.myserver.com:myapp.git#egg=myapp

But because this old-style “scp” syntax is not supported, it looks like I need to pass the full path to pip.

Here is how I am working around it:

pip install -e git+ssh://git@git.myserver.com/home/git/myapp.git#egg=myapp

# Or, alternatively (after reading the git clone manpage) - the ~git expands to the correct dir:
pip install -e git+ssh://git@git.myserver.com/~git/myapp.git#egg=myapp

In ssh:// you separate the domain and the path with a slash (/), not a colon (:). Please read your input cafully and compare thow it’s different from the examples.

something like this works for me

pip install -e git+ssh://git@git.example.de/mygroup/myproject.git@1.0#egg=myproject