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

Poetry fails to find Git on Windows 10 #7320

Open
4 tasks done
mrlegohead0x45 opened this issue Jan 8, 2023 · 5 comments · May be fixed by python-poetry/poetry-core#674
Open
4 tasks done

Poetry fails to find Git on Windows 10 #7320

mrlegohead0x45 opened this issue Jan 8, 2023 · 5 comments · May be fixed by python-poetry/poetry-core#674
Labels
kind/bug Something isn't working as expected status/triage This issue needs to be triaged

Comments

@mrlegohead0x45
Copy link

mrlegohead0x45 commented Jan 8, 2023

  • Poetry version: 1.31
  • Python version: 3.10.4
  • OS version and name: Windows 10
  • pyproject.toml: n/a
  • I am on the latest stable Poetry version, installed using a recommended method.
  • I have searched the issues of this repo and believe that this is not a duplicate.
  • I have consulted the FAQ and blog for any relevant entries or release notes.
  • If an exception occurs when executing a command, I executed it again in debug mode (-vvv option) and have included the output below.
powershell> poetry new pygame-test -vvv

  Stack trace:

  9  AppData\Roaming\pypoetry\venv\lib\site-packages\cleo\application.py:327 in run
      325│
      326│             try:
    → 327│                 exit_code = self._run(io)
      328│             except BrokenPipeError:
      329│                 # If we are piped to another process, it may close early and send a

  8  AppData\Roaming\pypoetry\venv\lib\site-packages\poetry\console\application.py:190 in _run
      188│         self._load_plugins(io)
      189│
    → 190│         exit_code: int = super()._run(io)
      191│         return exit_code
      192│

  7  AppData\Roaming\pypoetry\venv\lib\site-packages\cleo\application.py:431 in _run
      429│             io.input.interactive(interactive)
      430│
    → 431│         exit_code = self._run_command(command, io)
      432│         self._running_command = None
      433│

  6  AppData\Roaming\pypoetry\venv\lib\site-packages\cleo\application.py:473 in _run_command
      471│
      472│         if error is not None:
    → 473│             raise error
      474│
      475│         return terminate_event.exit_code

  5  AppData\Roaming\pypoetry\venv\lib\site-packages\cleo\application.py:457 in _run_command
      455│
      456│             if command_event.command_should_run():
    → 457│                 exit_code = command.run(io)
      458│             else:
      459│                 exit_code = ConsoleCommandEvent.RETURN_CODE_DISABLED

  4  AppData\Roaming\pypoetry\venv\lib\site-packages\cleo\commands\base_command.py:119 in run
      117│         io.input.validate()
      118│
    → 119│         status_code = self.execute(io)
      120│
      121│         if status_code is None:

  3  AppData\Roaming\pypoetry\venv\lib\site-packages\cleo\commands\command.py:62 in execute
       60│
       61│         try:
    →  62│             return self.handle()
       63│         except KeyboardInterrupt:
       64│             return 1

  2  AppData\Roaming\pypoetry\venv\lib\site-packages\poetry\console\commands\new.py:66 in handle
       64│         readme_format = self.option("readme") or "md"
       65│
    →  66│         config = GitConfig()
       67│         author = None
       68│         if config.get("user.name"):

  1  AppData\Roaming\pypoetry\venv\lib\site-packages\poetry\core\vcs\git.py:199 in __init__
      197│         try:
      198│             config_list = subprocess.check_output(
    → 199│                 [executable(), "config", "-l"], stderr=subprocess.STDOUT
      200│             ).decode()
      201│

  RuntimeError

  Unable to find a valid git executable

  at AppData\Roaming\pypoetry\venv\lib\site-packages\poetry\core\vcs\git.py:182 in executable
      178│     else:
      179│         _executable = "git"
      180│
      181│     if _executable is None:
    → 182│         raise RuntimeError("Unable to find a valid git executable")
      183│
      184│     return _executable
      185│
      186│
powershell> git --version
git version 2.34.1.windows.1

Issue

Trying to create a new poetry project on windows 10 fails saying it hasn't found git.
I recently updated poetry from 1.1.13 to 1.3.1 by running poetry self update and copying ~\AppData\Roaming\pypoetry\venv\Scripts\poetry.exe to ~\AppData\Roaming\Python\Scripts\poetry.exe as suggested in #5377. That worked.
Then trying to create a new project via poetry new, poetry complains that it hasn't found a valid git executable, when git is in PATH, looking at the source code it trys to run %WINDIR%\\System32\\where.exe git, running this command in cmd finds git successfully.
Maybe poetry requires a newer version of git than 2.34 which I have, seeing that the latest is 2.39?

@mrlegohead0x45 mrlegohead0x45 added kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Jan 8, 2023
@neersighted
Copy link
Member

Poetry shouldn't require a Git executable on Windows since we use Dulwich now. Can you please post the output of poetry config?

@mrlegohead0x45
Copy link
Author

powershell> poetry config --list
cache-dir = "C:\\Users\\mrlegohead\\AppData\\Local\\pypoetry\\Cache"
experimental.new-installer = true
experimental.system-git-client = false
installer.max-workers = null
installer.no-binary = null
installer.parallel = true
repositories.pypi_test.url = "https://test.pypi.org/legacy/"
virtualenvs.create = true
virtualenvs.in-project = null
virtualenvs.options.always-copy = false
virtualenvs.options.no-pip = false
virtualenvs.options.no-setuptools = false
virtualenvs.options.system-site-packages = false
virtualenvs.path = "{cache-dir}\\virtualenvs"  # C:\Users\mrlegohead\AppData\Local\pypoetry\Cache\virtualenvs
virtualenvs.prefer-active-python = false
virtualenvs.prompt = "{project_name}-py{python_version}"

@Secrus
Copy link
Member

Secrus commented Jan 8, 2023

I would suggest you uninstall Poetry all together and reinstall it. My guess would be that something went wrong with 1.1.13 -> 1.3.1 migration and files got mixed up or something

@tonybarbieri
Copy link

@neersighted @Secrus I am hitting the same issue using a fresh install of poetry 1.4.0. I am on Windows using Powershell. I installed git and python using scoop. Running 'poetry new' I get the same stack trace as above.

@LexSong
Copy link

LexSong commented Mar 12, 2023

check #5420

It seems that if the git.exe is in the sub-directory of the current folder will have this issue.
A temporary workaround is create a new folder and run poetry new in it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working as expected status/triage This issue needs to be triaged
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants