Troubleshooting poetry HangupException

Photo by RetroSupply on Unsplash

Troubleshooting poetry HangupException


I am working on a python project that uses poetry as the package manager. Everything has been working as expected, which is quite nice.

Recently however, I introduced a change to run some tests in the ci pipeline on github. This meant that I needed to install the dependencies on the github runner.

And that is where the problem began.

What happened?

On pushing my changes to the branch, the unit-test job failed with the error:


The remote server unexpectedly closed the connection.

And a few stacktraces later, another one:

The following error occurred when trying to handle this error:


Host key verification failed.

It was not obvious to me at first why this was error was being thrown, given that it was happening when trying to install a public package(python-dateutil).

After a bit of head-scratching and googling to no avail, I added the verbose output option to the poetry install command to get more info on the error. And it turned out the error was happening because I had a private repository as part of my dependencies, and poetry did not have the permission to clone it. The error message was a bit more helpful now:

  Failed to clone, check your git configuration and permissions for this repository.

Oh, so it turned out that since I did not have ssh authentication enabled from the github runner, poetry was failing to fetch the repository. In my scenario, doing this was not the best option and so I opted for the solution below.

How did you solve it?

This discussion on poetry repository was the answer I was looking for. There are different solutions there, but the one that worked for me was this:

git config --global url."".insteadOf

This change is written to git's global configuration file(~/.gitconfig).

And voila, poetry install now works again as expected, and so are the tests.

I could not have hoped for a happier ending than this one.