GitPython icon indicating copy to clipboard operation
GitPython copied to clipboard

Bad git executable

Open haferburg opened this issue 1 year ago • 2 comments

This is the full message:

  Traceback (most recent call last):

    File "C:\Users\AHaferbu\.pyenv\pyenv-win\versions\3.9.6\lib\site-packages\git\__init__.py", line 83, in <module>
      refresh()
    File "C:\Users\AHaferbu\.pyenv\pyenv-win\versions\3.9.6\lib\site-packages\git\__init__.py", line 73, in refresh
      if not Git.refresh(path=path):
    File "C:\Users\AHaferbu\.pyenv\pyenv-win\versions\3.9.6\lib\site-packages\git\cmd.py", line 278, in refresh
      raise ImportError(err)

  ImportError: Bad git executable.

  The git executable must be specified in one of the following ways:

      - be included in your $PATH
      - be set via $GIT_PYTHON_GIT_EXECUTABLE
      - explicitly set via git.refresh()
 
  All git commands will error until this is rectified.

This error message could be much more helpful.

Which git executable is it trying to run? Why? Where did it find that path? Is it using the PATH? Is it using GIT_PYTHON_GIT_EXECUTABLE?

haferburg avatar Mar 20 '24 15:03 haferburg

Thanks for sharing - I agree.

The code for this is here, in case anyone wants to give it a shot:

https://github.com/gitpython-developers/GitPython/blob/64ec0b1f86ada5565e30bc21b4ad189c6c4df49e/git/cmd.py#L463-L476

Byron avatar Mar 20 '24 15:03 Byron

This relates to the inconsistency discussed in https://github.com/gitpython-developers/GitPython/pull/1815#issuecomment-1929080774 and could be partially fixed by making initial refresh exception and logging messages include the path, as subsequent refresh messages have done since #1812. (I say "partially" because that would still not directly tell the user how that specific git executable path was set or discovered.)

EliahKagan avatar Apr 01 '24 17:04 EliahKagan