pip install with private requirements fails

Viewed 675

I have the following requirements.txt file:

git+ssh://git@bitbucket.org/.../...git@4.19.0#subdirectory=py 
git+ssh://git@bitbucket.org/.../...git@c99b7f6f372c92832eecfb90663833ef1fd3dc62
git+ssh://git@bitbucket.org/.../...git@45d2999ce5f6eba5dd728414073a10d1c50616a2
git+ssh://git@bitbucket.org/.../....git@1ba2781cd2beae6d23218565c395b633b0eb5328

When I try to install it however, it fails:

$ pip install -r requirements.txt
Collecting git+ssh://****@bitbucket.org/.../...git@4.19.0#subdirectory=py (from -r requirements.txt (line 8))
Cloning ssh://****@bitbucket.org/.../...git (to revision 4.19.0) to c:\users\...\appdata\local\temp\pip-req-build-t9_wrhxh
ERROR: Command errored out with exit status 128: git clone -q 'ssh://****@bitbucket.org/.../...git' 'C:\Users\...\AppData\Local\Temp\pip-req-build-t9_wrhxh' Check the logs for full command output.

Other colleagues are able to install requirements... what causes this? If I clone in the same was as shown by that error message it works fine:

$ git clone ssh://git@bitbucket.org/.../....git
Cloning into '...'... 
Enter passphrase for key '/c/Users/.../.ssh/id_rsa': 
remote: Counting objects: 2053, done. 
remote: Compressing objects: 100% (1648/1648), done. 
remote: Total 2053 (delta 1279), reused 385 (delta 200) 
Receiving objects: 100% (2053/2053), 1.88 MiB | 611.00 KiB/s, done. Resolving deltas: 100% (1279/1279), done.
1 Answers
$ pip install -r requirements.txt
...
ERROR: Command errored out with exit status 128: 
   git clone -q 'ssh://****@bitbucket.org/.../...git' 'C:\Users\...\AppData\Local\Temp\pip-req-build-t9_wrhxh'
   Check the logs for full command output.

This line from running pip install includes the command being executed. It is just a normal git clone writing to a temporary directory (which can be ignored) that is failing. The -q (quiet) flag is suppressing some of the output.

$ git clone ssh://git@bitbucket.org/.../....git
...
Enter passphrase for key '/c/Users/.../.ssh/id_rsa': 

This line from cloning directly indicates that whilst the clone is successful the key used to authenticate with bitbucket has a passphrase. When cloning in an interactive process, git is able to prompt for it - but that is not true in a none interactive process (such as pip).

Solution

There are multiple ways to solve this but the simplest would be:

  • Create a new ssh key pair without a passphrase
  • Add this key to your bitbucket account
  • Configure ssh to use this key with bitbucket.org
Host bitbucket.org
   IdentityFile ~/.ssh/no_passphrase.id_rsa
  • success
Related