2

I am using poetry 1.4.0 on ubuntu 22.04, and trying to add a specific git branch into my project :

poetry add git+ssh://git@dev/home/git/projects/jaydebeapi#nanosecond_fix

Failed to clone ssh://git@dev/home/git/projects/jaydebeapi at 'nanosecond_fix', verify ref exists on remote.

This is strange because manual git clone works :

git clone -b nanosecond_fix ssh://git@dev/home/git/projects/jaydebeapi
Cloning into 'jaydebeapi'...
remote: Counting objects: 1592, done.
remote: Compressing objects: 100% (572/572), done.
remote: Total 1592 (delta 879), reused 1592 (delta 879)
Receiving objects: 100% (1592/1592), 397.30 KiB | 4.14 MiB/s, done.
Resolving deltas: 100% (879/879), done.

Any idea ?

NOTE : GIT version is 2.34.1 on both server and client

Eric
  • 4,821
  • 6
  • 33
  • 60
  • Please try to use correct upper case letters, e.g. in the beginning of your title, sentences or the word "I". This would be gentle to your readers. – buhtz Mar 20 '23 at 10:03
  • Maybe an issue with Poetry's internal git client. You could disable it via the [*`experimental.system-git-client`*](https://python-poetry.org/docs/configuration/#experimentalsystem-git-client) config setting, and see if it improves. – sinoroc Mar 20 '23 at 22:16

2 Answers2

3

Just in case, as in issue 835, verify the remote branch does exist.

The manual clone you have done would check out by default the main branch, not a 'nanosecond_fix' branch.

Inside your manual clone, though, you can list all local and remote branches:

git branch -avv

If the branch exists, you can switch branch in a bare repository:

git symbolic-ref HEAD refs/heads/nanosecond_fix 
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Inside my manual clone the branch `nanosecond_fix` does exist (seen with branch -avv command) – Eric Mar 20 '23 at 07:51
  • @Eric Does `origin/nanosecond_fix` exist? – VonC Mar 20 '23 at 07:53
  • origin/nanosecond_fix does exist – Eric Mar 20 '23 at 09:56
  • @Eric Then updating Git might be a good idea indeed. – VonC Mar 20 '23 at 10:17
  • I just did it : both client and server are now 2.34.1 but still the same thing ... Am now debugging by putting some traces in poetry... – Eric Mar 20 '23 at 13:27
  • I tried `git remote set-head origin nanosecond_fix` but it did not work. But If I edit the `HEAD` file in the remote repository and put `refs/heads/nanosecond_fix` instead of `refs/heads/master` then it works. – Eric Mar 20 '23 at 14:32
  • @Eric Instead of that, can you try `git switch nanosecond_fix` – VonC Mar 20 '23 at 14:51
  • @ VonC : git switch does not work on a remote bare git repository. – Eric Mar 20 '23 at 16:36
  • 1
    @Eric Then using [`git symbolic-ref HEAD refs/heads/mybranch`](https://stackoverflow.com/a/3302018/6309) would be the preferred option, rather than editing directly some file. – VonC Mar 20 '23 at 21:34
0

Put this on your dependencies pyproject.toml:

[tool.poetry.dependencies]
repository_name = { git = "git@github.com/myorganization/myprivaterepo.git", branch = "master" }
fredmanre
  • 111
  • 1
  • 5
  • I had already tried with branch="nanosecond_fix" (the banch I wanted) but the message is the same. – Eric Mar 20 '23 at 07:41
  • Please try to use correct upper case letters, e.g. in the beginning of your sentences. This would be gentle to your readers. – buhtz Mar 20 '23 at 10:04