Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

import git fails when current working directory doesn't exist #1319

Closed
@bluenote10

Description

@bluenote10

Steps to reproduce:

$ mkdir /tmp/dir_to_be_deleted$cd /tmp/dir_to_be_deleted$ rmdir /tmp/dir_to_be_deleted$ python -c"import git"

Crashes with

Traceback (most recent call last):  File "/home/me/.virtualenvs/default/lib/python3.8/site-packages/git/__init__.py", line 87, in <module>    refresh()  File "/home/me/.virtualenvs/default/lib/python3.8/site-packages/git/__init__.py", line 76, in refresh    if not Git.refresh(path=path):  File "/home/me/.virtualenvs/default/lib/python3.8/site-packages/git/cmd.py", line 243, in refresh    cls().version()  File "/home/me/.virtualenvs/default/lib/python3.8/site-packages/git/cmd.py", line 585, in <lambda>    return lambda *args, **kwargs: self._call_process(name, *args, **kwargs)  File "/home/me/.virtualenvs/default/lib/python3.8/site-packages/git/cmd.py", line 1124, in _call_process    return self.execute(call, **exec_kwargs)  File "/home/me/.virtualenvs/default/lib/python3.8/site-packages/git/cmd.py", line 782, in execute    cwd = self._working_dir or os.getcwd()FileNotFoundError: [Errno 2] No such file or directoryThe above exception was the direct cause of the following exception:Traceback (most recent call last):  File "<string>", line 1, in <module>  File "/home/me/.virtualenvs/default/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: [Errno 2] No such file or directory

In generalos.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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp