Poetry add/install using ssh+git fails
Asked Answered
A

2

10

I am trying to add depedency from git to poetry using SSH ( I am not interested in HTTPS version). The but I get an error whether I use poetry add...

poetry add git+ssh://[email protected]:myorg/myproj.git

...or if I add it manually...

# Entry in pyproject.toml
myproj = { git = "[email protected]:myorg/myproj.git" }
# cmd
poetry install

In both cases, I get the following output:

Stack trace:

  11  ~\AppData\Roaming\pypoetry\venv\lib\site-packages\clikit\console_application.py:131 in run
      status_code = command.handle(parsed_args, io)

  10  ~\AppData\Roaming\pypoetry\venv\lib\site-packages\clikit\api\command\command.py:120 in handle
      status_code = self._do_handle(args, io)

   9  ~\AppData\Roaming\pypoetry\venv\lib\site-packages\clikit\api\command\command.py:171 in _do_handle
      return getattr(handler, handler_method)(args, io, self)

   8  ~\AppData\Roaming\pypoetry\venv\lib\site-packages\cleo\commands\command.py:92 in wrap_handle
      return self.handle()

   7  ~\AppData\Roaming\pypoetry\venv\lib\site-packages\poetry\console\commands\add.py:106 in handle
      requirements = self._determine_requirements(

   6  ~\AppData\Roaming\pypoetry\venv\lib\site-packages\poetry\console\commands\init.py:320 in _determine_requirements
      requires = self._parse_requirements(requires)

   5  ~\AppData\Roaming\pypoetry\venv\lib\site-packages\poetry\console\commands\init.py:410 in _parse_requirements
      package = Provider.get_package_from_vcs(

   4  ~\AppData\Roaming\pypoetry\venv\lib\site-packages\poetry\puzzle\provider.py:193 in get_package_from_vcs
      git.clone(url, tmp_dir)

   3  ~\AppData\Roaming\pypoetry\venv\lib\site-packages\poetry\core\vcs\git.py:262 in clone
      return self.run("clone", "--recurse-submodules", "--", repository, str(dest))

   2  ~\AppData\Roaming\pypoetry\venv\lib\site-packages\poetry\core\vcs\git.py:356 in run
      subprocess.check_output(

   1  ~\AppData\Local\Programs\Python\Python310\lib\subprocess.py:420 in check_output
      return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,

  CalledProcessError

  Command '['C:\\Program Files\\Git\\cmd\\git.exe', 'clone', '--recurse-submodules', '--', '[email protected]:myorg/myproj.git', 'C:\\Users\\Adeom\\AppData\\Local\\Temp\\pypoetry-git-myprojwhjkd872g']' returned non-zero exit status 128.

  at ~\AppData\Roaming\pypoetry\venv\lib\site-packages\poetry\utils\_compat.py:217 in run
      213│                 process.wait()
      214│                 raise
      215│             retcode = process.poll()
      216│             if check and retcode:
    → 217│                 raise CalledProcessError(
      218│                     retcode, process.args, output=stdout, stderr=stderr
      219│                 )
      220│         finally:
      221│             # None because our context manager __exit__ does not use them.

Poetry never asks for my SSH key password. I have tested cloning via git from commandline using ssh, and it works fine.

What am I doing incorrectly?

Apocalyptic answered 30/1, 2022 at 11:26 Comment(3)
I never tested it, but I can think of two options: (1) switch to HTTPS. (2) What happens when you do a normal git clone or something similar using SSH? Do you need to provide a password? Try to skip this need (e.g. add to keyring or something like that).Godiva
did you find an answer to this? im having the same problem. my ssh_agent seems to be working fine otherwise..Gordie
Never found a solution. At the time of me asking this, the search ended with poetry not supporting this.Apocalyptic
T
3

You didn't specify the git path correctly. git clone and pip/poetry ask for different formatting of the GitHub repo path you should do myproj = { git = "git+ssh://[email protected]/myorg/myproj.git" } so, specifically:

  • set the protocol to git+ssh
  • path to you repo within GitHub is separated not by : but by /.

I had the same issue and tried to use pip directly, and pip told me that it couldn't find my repo. After I fixed the path, to what I wrote above it started working. Poetry doesn't really explain what is going on.

If your branch is main on GitHub, you also need to specify it by adding branch="main", otherwise it'll attempt to do master.

Thuthucydides answered 26/3, 2023 at 15:9 Comment(0)
S
0

I still have an issue (not this one on closer inspection), however when looking closely at the line with the time counter:

Resolving dependencies... (3.1s)

I noticed there was a flash of Enter passphrase for key 'my_key_here':

So I decided to just type the password to unlock the ssh private key and voila, it works... So, the time counter is obscuring the password prompt it seems.

Scurrility answered 14/8, 2024 at 11:48 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.