Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

git install doesn't recognize new main default branch #3366

Closed
wasdee opened this issue Nov 15, 2020 · 22 comments · Fixed by python-poetry/poetry-core#143
Closed

git install doesn't recognize new main default branch #3366

wasdee opened this issue Nov 15, 2020 · 22 comments · Fixed by python-poetry/poetry-core#143
Labels
kind/bug Something isn't working as expected

Comments

@wasdee
Copy link
Contributor

wasdee commented Nov 15, 2020

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
@wasdee wasdee added kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Nov 15, 2020
@wasdee
Copy link
Contributor Author

wasdee commented Nov 15, 2020

I could create a PR if you like.

@sinoroc
Copy link

sinoroc commented Nov 15, 2020

Based on what clue should it be decided to go for master or main?

the default branch name has changed

Where? In git, in github, in your own projects?

Can the default branch name be auto-detected somehow?

@wasdee
Copy link
Contributor Author

wasdee commented Nov 16, 2020

@sinoroc github has changed for all newly created repo. https://www.zdnet.com/article/github-to-replace-master-with-main-starting-next-month/

My impulse answer would be to check (or to try-catch) starting for 'master' then 'main'.

or, we can derive the implementation from pip.

@wasdee
Copy link
Contributor Author

wasdee commented Nov 16, 2020

One thing to note also that, the verbose message of the error is not really helpful if not looking carefully. The verbose message should tell the user about the cause that the target branch is not exist.

@abn
Copy link
Member

abn commented Nov 16, 2020

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.

@sinoroc
Copy link

sinoroc commented Nov 16, 2020

The only meaningful direct reference in code I could find is there:

        if not any([branch, tag, rev]):
            # If nothing has been specified, we assume master
            branch = "master"

The rest of the code should probably be adapted to work when branch, tag and rev are all None.

@Armaxxx
Copy link

Armaxxx commented Dec 2, 2020

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

@sinoroc
Copy link

sinoroc commented Dec 2, 2020

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.

@Armaxxx
Copy link

Armaxxx commented Dec 3, 2020

This is definitely a dumb question, but I need to work on poetry-core, right? Not in the poetry repo.

@sinoroc
Copy link

sinoroc commented Dec 3, 2020

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.

@Shams66789
Copy link

Is it still open ? I would like to take it as my first issue.

@wasdee
Copy link
Contributor Author

wasdee commented Jan 19, 2021

Is it still open ? I would like to take it as my first issue.

You might want to take a look here first. python-poetry/poetry-core#117

@abn
Copy link
Member

abn commented Mar 28, 2021

Reopening as the PR was reverted.

@marcoaaguiar
Copy link

What is the status of this? It was opened and closed, merged and reverted, so many times that I got lost 😟

@lambdalisue
Copy link

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

@lambdalisue
Copy link

I still faced this issue on the latest Poetry (1.1.7)...

@grimmer0125
Copy link

I have submitted a PR to solve this, #4386.

@joooeey
Copy link

joooeey commented Nov 2, 2021

Here's the set of steps to reproduce the same issue occuring when I edit the pyproject.toml file. Note that #4386 as it is now would not solve the problem in my case because it relies on editing pyproject.toml. I think this should be solved further upstream.

Steps:

  1. cd ~/Desktop
  2. poetry new poetry-demo
  3. Edit pyproject.toml to include:
[tool.poetry.dependencies]
python = "^3.8"  # Leave this line as it is.
sentinelsat = { git = "https://github.com/sentinelsat/sentinelsat.git" }
  1. cd poetry-demo
  2. poetry install

resutls in:

  CalledProcessError

  Command '['git', '--git-dir', '/tmp/pypoetry-git-sentinelsao21ujftz/.git', '--work-tree', '/tmp/pypoetry-git-sentinelsao21ujftz', '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.

Workaround:

Use sentinelsat = { git = "https://github.com/sentinelsat/sentinelsat.git", branch = "main" }. This is the workaround that #4386 uses. However, if possible it would be better to address this deeper inside Poetry.

@grimmer0125
Copy link

grimmer0125 commented Nov 3, 2021

Here's the set of steps to reproduce the same issue occuring when I edit the pyproject.toml file. Note that #4386 as it is now would not solve the problem in my case because it relies on editing pyproject.toml. I think this should be solved further upstream.

@joooeey
For your direct modifying pyproject.toml case, #4386 can work with python-poetry/poetry-core/pull/192 to solve that case, and pyproject.toml will keep sentinelsat = { git = "https://github.com/sentinelsat/sentinelsat.git"} in the end. More detail is in #4386 (comment).

@hugolytics
Copy link

My poetry packages are not installable from git unless i specify the #main branch.
Is this going to be resolved or should i always install this way?

@finswimmer
Copy link
Member

It is fixed by python-poetry/poetry-core#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).

Copy link

github-actions bot commented Mar 1, 2024

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.