python-poetry / python-poetry/poetry

Poetry fails to find Git on Windows 10

Open
#7,320 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

kind/bug status/triage
Dominant language
Python
Stars
34.3k
Forks
2.5k
Avg merge
2d 19h
Merged PRs (30d)
30

Description

  • 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?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with poetry/core/vcs/git.py at the executable lookup and poetry/console/commands/new.py where GitConfig is created. Reproduce poetry new pygame-test -vvv on Windows 10 with Git available in PATH, then inspect why the executable check differs from the successful git --version command. Done means poetry new can find and use the installed Git executable.

Written by the indexing model from the issue text.

Assessment

Tech stack
git, python
Domain
cli, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.