Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork944
Closed
Milestone
Description
Very similar to#1319
Steps to reproduce:
$ mkdir /tmp/foo$cd /tmp/foo$ chmod -x.$ python -c"import git"
Crash with:
Traceback (most recent call last): File "/home/comzyh/.local/lib/python3.8/site-packages/git/__init__.py", line 87, in <module> refresh() File "/home/comzyh/.local/lib/python3.8/site-packages/git/__init__.py", line 76, in refresh if not Git.refresh(path=path): File "/home/comzyh/.local/lib/python3.8/site-packages/git/cmd.py", line 305, 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 initial warning 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|none|n|0: for no warning or exception - warn|w|warning|1: for a printed warning - error|e|raise|r|2: for a raised exceptionExample: export GIT_PYTHON_REFRESH=quietThe above exception was the direct cause of the following exception:Traceback (most recent call last): File "<string>", line 1, in <module> File "/home/comzyh/.local/lib/python3.8/site-packages/git/__init__.py", line 89, in <module> raise ImportError('Failed to initialize: {0}'.format(exc)) from excImportError: 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()All git commands will error until this is rectified.This initial warning 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|none|n|0: for no warning or exception - warn|w|warning|1: for a printed warning - error|e|raise|r|2: for a raised exceptionExample: export GIT_PYTHON_REFRESH=quiet
GitPython: 3.1.20
GitPython will run agit version
when importing, but if the current workding dir is not accessible, the Popen clause will fail.
Line 821 inef1ef4d
cwd=cwd, |
This can be fixed by adding 2 lines after5b3669e, but I'm not sure if this fix will break some of your assumption.
# Allow the user to have the command executed in their working dir.try:cwd=self._working_diroros.getcwd()# type: Union[None, str]exceptFileNotFoundError:cwd=Noneifnotos.access(cwd,os.X_OK):cwd=None
I found this issue when I'm a previliedged user and try to switch user usingsudo su <user>
and then run a Python script which need a package depending on GitPython.
Metadata
Metadata
Assignees
Labels
No labels