- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 933
import git
fails when current working directory doesn't exist
#1319
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
Comments
Thanks for the report. I understand that it's probably a bit strange that it needs the CWD to just be imported. |
Yes lazily would probably be the most elegant solution, because it is in the Python-best-practices-spirit of not executing anything that can throw at import time. If you want a quick-and-dirty solution though, it should also be sufficient to replace Line 784 in ea1a03a
with try:
cwd = self._working_dir or os.getcwd()
except FileNotFoundError:
cwd = None This should work, because |
Thanks a lot for the suggestion. Since it was added as is I assume this particular issue will be resolved. Maybe there are other stumbling blocks though, and if so please feel free to post here so the issue can be reopened. |
Steps to reproduce:
Crashes with
In general
os.getcwd()
needs to guarded againstFileNotFoundError
because of the possibility that there is no valid working directory.GitPython version:
3.1.18
This is certainly not a big issue, but it can be very confusing, and there is (probabaly) not theoretical reason why GitPython cannot work in this case.
The text was updated successfully, but these errors were encountered: