poetry: git install doesn't recognize new `main` default branch

poetry add git+https://github.com/AGeekInside/fastapi-jinja.git result in exception since it is tires to checkout master branch.

poetry add git+https://github.com/AGeekInside/fastapi-jinja.git

Updating dependencies
Resolving dependencies...

  CalledProcessError

  Command '['git', '--git-dir', 'C:/Users/n2/AppData/Local/Temp/pypoetry-git-fastapi-jinjau3blv69e/.git', '--work-tree', 'C:/Users/n2/AppData/Local/Temp/pypoetry-git-fastapi-jinjau3blv69e', 'checkout', 'master']' returned non-zero exit status 1.

  at ~\.poetry\lib\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.

as the default branch name has changed, poetry should both accept main and master.

the workaround is

  1. poetry add git+https://github.com/AGeekInside/fastapi-jinja.git#main
  2. pip install git+https://github.com/AGeekInside/fastapi-jinja.git

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 16
  • Comments: 22 (7 by maintainers)

Commits related to this issue

Most upvoted comments

Poetry should simply not specify a branch by default. This should then default to whatever is the server default and this should adhere to expected behaviour. Might require removing this “master is default” assumption at multiple points in the code. PR welcome.

As for the error messages. There is very little we can do here at the moment since the git command is being processed as a subprocess call and errors can happen at various nested levels. Moving to a native python library will help with this in the future. As for immideate improvements, if you can identify any easy wins within the current error handling, PR is welcome, but maybe open another issue for that.

I still faced this issue on the latest Poetry (1.1.6)

Is this still open? I could try to tackle this as my first issue.

Yes, as far as I can tell, there is no PR yet so you’d be first.

It is fixed by https://github.com/python-poetry/poetry-core/pull/192 which is available in poetry-core 1.1.0a7. So this will be fixed by (re)intalling the latest poetry pre-release version (1.2.0a2).

I need to work on poetry-core, right? Not in the poetry repo.

As far as I can tell, yes. At least, I would start with poetry-core. Then it will show if some more modifications are needed in poetry or not.

Is this still open? I could try to tackle this as my first issue.