在 Github Actions 中使用 Poetry 时如何解决 JSONDecodeError?

Gui*_*urd 6 python github-actions python-poetry python-3.10

问题

\n

poetry install自从我从 Python 3.8 迁移到 Python 3.10 以来,我在任何 GitHub 运行器上的 CI/CD 管道(Github Actions)中使用时都遇到问题。

\n
Installing dependencies from lock file\n\nPackage operations: 79 installs, 0 updates, 0 removals\n  \xe2\x80\xa2 Installing pyparsing (3.0.9)\n  \nJSONDecodeError\n  \nExpecting value: line 1 column 1 (char 0)\n  at /opt/hostedtoolcache/Python/3.10.0/x64/lib/python3.10/json/decoder.py:355 in raw_decode\n      351\xe2\x94\x82         """\n      352\xe2\x94\x82         try:\n      353\xe2\x94\x82             obj, end = self.scan_once(s, idx)\n      354\xe2\x94\x82         except StopIteration as err:\n    \xe2\x86\x92 355\xe2\x94\x82             raise JSONDecodeError("Expecting value", s, err.value) from None\n      356\xe2\x94\x82         return obj, end\n      357\xe2\x94\x82 \nError: Process completed with exit code 1.\n
Run Code Online (Sandbox Code Playgroud)\n

我没有更改文件中的任何 lib 配置pyproject.toml,但正如您在上面看到的:Poetry 隐藏了大部分 StackTrace。

\n

我尝试过的

\n
    \n
  • 重新创建poetry.lock文件。
  • \n
  • rm -r ~/.cache/pypoetry/cache/使用(和)删除诗歌缓存rm -r ~/.cache/pypoetry/
  • \n
  • 删除返回错误的库(实际上,这个问题似乎发生在任何库上,所以这就是我理解它可能与诗歌和Python有关的原因)
  • \n
\n

问题

\n

知道如何解决我的 CI/CD 管道中的这个问题吗?

\n

Gui*_*urd 7

经过一些研究,我在 2021 年 11 月的诗歌 GitHub 存储库上找到了这个帖子。

hoefling GitHub 用户提供了一个解决方法:

禁用诗歌的实验性新安装程序可能是目前的一个解决方法:

解决方案

poetry config experimental.new-installer false
Run Code Online (Sandbox Code Playgroud)

在运行命令之前在 shell 中添加这一行poetry install解决了我的问题!



请注意,在同一线程中,ddc67cd的另一条评论指出:

新版本的cachecontrol==0.12.9解决了这个问题(它应该会自动安装)。

pip install -U cachecontrol在我的具体情况下,运行并没有解决问题(否则可能值得测试?)。



该问题似乎最近又出现了(2022 年 7 月),此评论暗示了与 setuptools 库相关的问题的可能根本原因。

无论如何,禁用诗歌的实验性新安装程序应该可以暂时解决问题,直到找到永久解决方案。