Skip to content

ImportError on latest GitPython 3.1.16 #1238

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

Closed
wwwaldo opened this issue May 13, 2021 · 5 comments · Fixed by #1240
Closed

ImportError on latest GitPython 3.1.16 #1238

wwwaldo opened this issue May 13, 2021 · 5 comments · Fixed by #1240

Comments

@wwwaldo
Copy link

wwwaldo commented May 13, 2021

Hey all,

Our CI doesn't pin GitPython versions (always use latest) and some of our automated tests failed today with a mysterious GitPython ImportError. Here's the stack trace:

[2021-05-13T15:23:58.759Z] ERROR launching hyper random, stderr: sh: 0: getcwd() failed: No such file or directory

[2021-05-13T15:23:58.759Z] Traceback (most recent call last):

[2021-05-13T15:23:58.759Z]   File "/usr/local/lib/python3.7/site-packages/git/__init__.py", line 83, in <module>

[2021-05-13T15:23:58.759Z]     refresh()

[2021-05-13T15:23:58.759Z]   File "/usr/local/lib/python3.7/site-packages/git/__init__.py", line 73, in refresh

[2021-05-13T15:23:58.759Z]     if not Git.refresh(path=path):

[2021-05-13T15:23:58.759Z]   File "/usr/local/lib/python3.7/site-packages/git/cmd.py", line 215, in refresh

[2021-05-13T15:23:58.759Z]     cls().version()

[2021-05-13T15:23:58.759Z]   File "/usr/local/lib/python3.7/site-packages/git/cmd.py", line 542, in <lambda>

[2021-05-13T15:23:58.759Z]     return lambda *args, **kwargs: self._call_process(name, *args, **kwargs)

[2021-05-13T15:23:58.759Z]   File "/usr/local/lib/python3.7/site-packages/git/cmd.py", line 1005, in _call_process

[2021-05-13T15:23:58.759Z]     return self.execute(call, **exec_kwargs)

[2021-05-13T15:23:58.759Z]   File "/usr/local/lib/python3.7/site-packages/git/cmd.py", line 686, in execute

[2021-05-13T15:23:58.759Z]     cwd = self._working_dir or os.getcwd()

[2021-05-13T15:23:58.759Z] FileNotFoundError: [Errno 2] No such file or directory

[2021-05-13T15:23:58.759Z] 

[2021-05-13T15:23:58.759Z] The above exception was the direct cause of the following exception:

[2021-05-13T15:23:58.760Z] 

[2021-05-13T15:23:58.760Z] Traceback (most recent call last):

[2021-05-13T15:23:58.760Z]   File "/usr/local/bin/spell", line 7, in <module>

[2021-05-13T15:23:58.760Z]     from spell.cli.main import main

[2021-05-13T15:23:58.760Z]   File "/usr/src/spell/python/spell/cli/main.py", line 47, in <module>

[2021-05-13T15:23:58.760Z]     from spell.cli.commands.run import run

[2021-05-13T15:23:58.760Z]   File "/usr/src/spell/python/spell/cli/commands/run.py", line 11, in <module>

[2021-05-13T15:23:58.760Z]     from spell.cli.utils import (

[2021-05-13T15:23:58.760Z]   File "/usr/src/spell/python/spell/cli/utils/git_utils.py", line 8, in <module>

[2021-05-13T15:23:58.760Z]     import git

[2021-05-13T15:23:58.760Z]   File "/usr/local/lib/python3.7/site-packages/git/__init__.py", line 85, in <module>

[2021-05-13T15:23:58.760Z]     raise ImportError('Failed to initialize: {0}'.format(exc)) from exc

[2021-05-13T15:23:58.760Z] ImportError: Failed to initialize: [Errno 2] No such file or directory

I think this might be a regression in the new 3.1.16.

Many of our other tests also seem to import the gitpython library but they don't error. The only difference I can see between the failed and passed tests is that the failed tests run in a parallel thread executor, all passing tests run one at a time.

@Yobmod
Copy link
Contributor

Yobmod commented May 13, 2021

I think its due to a change in util.Expand_path(), as self._working_dir = expand_path(working_dir).

But I don't know why it would only fail with parallel code.

I've reverted the change (it added a None check as working_dir can be None, but logic must have been wrong somewhere) and added type:ignore to the resulting mypy errors for now to pass CI #1240

@Byron
Copy link
Member

Byron commented May 13, 2021

I have yanked the release and will see to these issues in a bit.

@Byron Byron added this to the v3.1.17 - Bugfixes milestone May 14, 2021
@Byron
Copy link
Member

Byron commented May 14, 2021

@karenin-overseas It would be great if you could give the latest main a shot on your CI to see if the issue is indeed fixed. If so, I am happy to cut a new release. Thank you

@wwwaldo
Copy link
Author

wwwaldo commented May 14, 2021

@Byron, I'm able to verify that our CI does not error off main. Thanks

@Byron
Copy link
Member

Byron commented May 14, 2021

And here is the new release: https://pypi.org/project/GitPython/3.1.17/

netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this issue May 14, 2021
3.1.17
* Fix issues from 3.1.16 (see gitpython-developers/GitPython#1238)
* Fix issues from 3.1.15 (see gitpython-developers/GitPython#1223)
* Add more static typing information
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

3 participants