Skip to content

Silently ignore gitpython import errors. #319

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

Merged
merged 3 commits into from
Feb 21, 2025
Merged

Conversation

tcdent
Copy link
Collaborator

@tcdent tcdent commented Feb 18, 2025

gitpython will not import if git is not installed on the system.

Found this cuz I was testing install on a fresh container.

Big scary in case anyone encounters this:

Traceback (most recent call last):
  File "/root/.local/lib/python3.12/site-packages/git/__init__.py", line 296, in <module>
    refresh()
  File "/root/.local/lib/python3.12/site-packages/git/__init__.py", line 287, in refresh
    if not Git.refresh(path=path):
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.local/lib/python3.12/site-packages/git/cmd.py", line 631, 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(<full-path-to-git-executable>)

All git commands will error until this is rectified.

This initial message can be silenced or aggravated in the future by setting the
$GIT_PYTHON_REFRESH environment variable. Use one of the following values:
    - quiet|q|silence|s|silent|none|n|0: for no message or exception
    - warn|w|warning|log|l|1: for a warning message (logging level CRITICAL, displayed by default)
    - error|e|exception|raise|r|2: for a raised exception

Example:
    export GIT_PYTHON_REFRESH=quiet


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/root/.local/bin/agentstack", line 5, in <module>
    from agentstack.main import main
  File "/root/.local/lib/python3.12/site-packages/agentstack/main.py", line 7, in <module>
    from agentstack.cli import (
  File "/root/.local/lib/python3.12/site-packages/agentstack/cli/__init__.py", line 1, in <module>
    from .cli import (
  File "/root/.local/lib/python3.12/site-packages/agentstack/cli/cli.py", line 10, in <module>
    from agentstack import repo
  File "/root/.local/lib/python3.12/site-packages/agentstack/repo.py", line 4, in <module>
    import git
  File "/root/.local/lib/python3.12/site-packages/git/__init__.py", line 298, in <module>
    raise ImportError("Failed to initialize: {0}".format(_exc)) from _exc
ImportError: Failed to initialize: 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(<full-path-to-git-executable>)

All git commands will error until this is rectified.

This initial message can be silenced or aggravated in the future by setting the
$GIT_PYTHON_REFRESH environment variable. Use one of the following values:
    - quiet|q|silence|s|silent|none|n|0: for no message or exception
    - warn|w|warning|log|l|1: for a warning message (logging level CRITICAL, displayed by default)
    - error|e|exception|raise|r|2: for a raised exception

Example:
    export GIT_PYTHON_REFRESH=quiet
    ```

@bboynton97
Copy link
Contributor

def dont want big scary

@tcdent tcdent merged commit 0414fc8 into AgentOps-AI:main Feb 21, 2025
7 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants