How to solve JSONDecodeError when using Poetry in Github Actions?
Question:
Issue
I’ve got a problem using poetry install
in my CI/CD pipeline (Github Actions), on any GitHub runner, since I migrated from Python 3.8 to Python 3.10.
Installing dependencies from lock file
Package operations: 79 installs, 0 updates, 0 removals
• Installing pyparsing (3.0.9)
JSONDecodeError
Expecting value: line 1 column 1 (char 0)
at /opt/hostedtoolcache/Python/3.10.0/x64/lib/python3.10/json/decoder.py:355 in raw_decode
351│ """
352│ try:
353│ obj, end = self.scan_once(s, idx)
354│ except StopIteration as err:
→ 355│ raise JSONDecodeError("Expecting value", s, err.value) from None
356│ return obj, end
357│
Error: Process completed with exit code 1.
I didn’t change any lib configuration in my pyproject.toml
file, but as you can see above: Poetry hides most of the StackTrace.
What I tried
- Recreating the
poetry.lock
file.
- Removing the Poetry cache using
rm -r ~/.cache/pypoetry/cache/
(and rm -r ~/.cache/pypoetry/
).
- Removing the lib that was returning an error (actually, the issue seems to happen with any lib, so that’s the reason why I understand it’s probably related to poetry and python)
Question
Any idea how to resolve this issue in my CI/CD pipeline?
Answers:
After a few researches, I found this thread on the poetry GitHub repository from november 2021.
There is this workaround from hoefling GitHub user:
Disabling poetry’s experimental new installer may be a workaround for
now:
Solution
poetry config experimental.new-installer false
Adding this line in the shell before running the poetry install
command resolved my problem!
Note that in the same thread, another comment from ddc67cd stated that:
the issue is resolved with the new version of cachecontrol==0.12.9 (it should be installed automatically).
But running pip install -U cachecontrol
didn’t resolve the issue in my specific case (might be worth testing otherwise?).
It also seems the problem came back recently (July 2022) and this comment suggested a possible root cause to the issue related to the setuptools library.
Anyway, disabling poetry’s experimental new installer should resolve the problem for now, until a permanent solution is found.
Issue
I’ve got a problem using poetry install
in my CI/CD pipeline (Github Actions), on any GitHub runner, since I migrated from Python 3.8 to Python 3.10.
Installing dependencies from lock file
Package operations: 79 installs, 0 updates, 0 removals
• Installing pyparsing (3.0.9)
JSONDecodeError
Expecting value: line 1 column 1 (char 0)
at /opt/hostedtoolcache/Python/3.10.0/x64/lib/python3.10/json/decoder.py:355 in raw_decode
351│ """
352│ try:
353│ obj, end = self.scan_once(s, idx)
354│ except StopIteration as err:
→ 355│ raise JSONDecodeError("Expecting value", s, err.value) from None
356│ return obj, end
357│
Error: Process completed with exit code 1.
I didn’t change any lib configuration in my pyproject.toml
file, but as you can see above: Poetry hides most of the StackTrace.
What I tried
- Recreating the
poetry.lock
file. - Removing the Poetry cache using
rm -r ~/.cache/pypoetry/cache/
(andrm -r ~/.cache/pypoetry/
). - Removing the lib that was returning an error (actually, the issue seems to happen with any lib, so that’s the reason why I understand it’s probably related to poetry and python)
Question
Any idea how to resolve this issue in my CI/CD pipeline?
After a few researches, I found this thread on the poetry GitHub repository from november 2021.
There is this workaround from hoefling GitHub user:
Disabling poetry’s experimental new installer may be a workaround for
now:
Solution
poetry config experimental.new-installer false
Adding this line in the shell before running the poetry install
command resolved my problem!
Note that in the same thread, another comment from ddc67cd stated that:
the issue is resolved with the new version of cachecontrol==0.12.9 (it should be installed automatically).
But running pip install -U cachecontrol
didn’t resolve the issue in my specific case (might be worth testing otherwise?).
It also seems the problem came back recently (July 2022) and this comment suggested a possible root cause to the issue related to the setuptools library.
Anyway, disabling poetry’s experimental new installer should resolve the problem for now, until a permanent solution is found.