libgit2 / libgit2/pygit2

"invalid config path selector" error when testing on pypy with MacOS arm64

オープン
#1,442 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

主要言語
Python
スター
1.7k
フォーク
408
平均マージ
2日 57分
マージ済み PR(30日)
7

説明

pytest output

../venv-test-arm64/lib/pypy3.11/site-packages/pygit2/errors.py:67: GitError
__________________ ERROR at setup of test_rebuild_treebuilder __________________

    @pytest.fixture(scope='session', autouse=True)
    def global_git_config() -> None:
        # Do not use global config for better test reproducibility.
        # https://github.com/libgit2/pygit2/issues/989
        levels = [
            pygit2.enums.ConfigLevel.GLOBAL,
            pygit2.enums.ConfigLevel.XDG,
            pygit2.enums.ConfigLevel.SYSTEM,
        ]
        for level in levels:
>           pygit2.settings.search_path[level] = ''
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

test/conftest.py:22: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
../venv-test-arm64/lib/pypy3.11/site-packages/pygit2/settings.py:45: in __setitem__
    option(Option.SET_SEARCH_PATH, key, value)
../venv-test-arm64/lib/pypy3.11/site-packages/pygit2/options.py:373: in option
    check_error(err)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

err = -1, io = False

    def check_error(err: int, io: bool = False) -> None:
        if err >= 0:
            return
    
        # These are special error codes, they should never reach here
        test = err != C.GIT_EUSER and err != C.GIT_PASSTHROUGH
        assert test, f'Unexpected error code {err}'
    
        # Error message
        giterr = C.git_error_last()
        if giterr != ffi.NULL:
            message = ffi.string(giterr.message).decode('utf8', errors='surrogateescape')
        else:
            message = f'err {err} (no message provided)'
    
        # Translate to Python errors
        if err in value_errors:
            raise ValueError(message)
    
        if err == C.GIT_ENOTFOUND:
            if io:
                raise IOError(message)
    
            raise KeyError(message)
    
        if err == C.GIT_EINVALIDSPEC:
            raise ValueError(message)
    
        if err == C.GIT_ITEROVER:
            raise StopIteration()
    
        # Generic Git error
>       raise GitError(message)
E       _pygit2.GitError: invalid config path selector 0

../venv-test-arm64/lib/pypy3.11/site-packages/pygit2/errors.py:67: GitError
ERROR test/test_treebuilder.py::test_rebuild_treebuilder - _pygit2.GitError: invalid config path selector 0


As far as I can tell, this "invalid config path selector" error seems to be specific to pygit2 on pypy11. It seems that the int(level) passed to git_libgit2_opts()

https://github.com/libgit2/pygit2/blob/890730c1394c4b36b2c07f8679cd4c39e612fc75/pygit2/options.py#L359-L374

is not matching up with the libgit2 C constants of the same name:

static int config_level_to_sysdir(int *out, int config_level)
{
	switch (config_level) {
	case GIT_CONFIG_LEVEL_SYSTEM:
		*out = GIT_SYSDIR_SYSTEM;
		return 0;
	case GIT_CONFIG_LEVEL_XDG:
		*out = GIT_SYSDIR_XDG;
		return 0;
	case GIT_CONFIG_LEVEL_GLOBAL:
		*out = GIT_SYSDIR_GLOBAL;
		return 0;
	case GIT_CONFIG_LEVEL_PROGRAMDATA:
		*out = GIT_SYSDIR_PROGRAMDATA;
		return 0;
	default:
		break;
	}

	git_error_set(
		GIT_ERROR_INVALID, "invalid config path selector %d", config_level);
	return -1;
}

See libgit2 source

There was a similar issue in https://github.com/libgit2/libgit2sharp/issues/1951 which was fixed by padding the va_args passed to git_libgit2_opts() (https://github.com/libgit2/libgit2sharp/pull/1955).

Originally posted by @2bndy5 in https://github.com/libgit2/pygit2/issues/1441#issuecomment-3610152291

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

pygit2/options.py の359-374行目と、test/conftest.py にある失敗するセットアップから始め、PyPy/macOS arm64 で test/test_treebuilder.py::test_rebuild_treebuilder を再現します。git_libgit2_opts() に渡される引数を、libgit2 の settings.c config_level_to_sysdir および類似する libgit2sharp の修正と比較します。その環境で fixture の設定検索パスの代入が成功すれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
c, python
領域
devtools
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
48/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。