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

Bad git executable #1882

Open
haferburg opened this issue Mar 20, 2024 · 2 comments
Open

Bad git executable #1882

haferburg opened this issue Mar 20, 2024 · 2 comments

Comments

@haferburg
Copy link

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?

@Byron
Copy link
Member

Byron commented Mar 20, 2024

Thanks for sharing - I agree.

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

GitPython/git/cmd.py

Lines 463 to 476 in 64ec0b1

# Warn or raise exception if test failed.
if not has_git:
err = (
dedent(
"""\
Bad git executable.
The git executable must be specified in one of the following ways:
- be included in your $PATH
- be set via $%s
- explicitly set via git.refresh(<full-path-to-git-executable>)
"""
)
% cls._git_exec_env_var
)

@EliahKagan
Copy link
Contributor

EliahKagan commented Apr 1, 2024

This relates to the inconsistency discussed in #1815 (comment) 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.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants