pio check hangs forever when the analyser executable is missing
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 78/100
Research direction
Read platformio/proc.py and inspect exec_command, especially how Popen and the AsyncPipeBase streams are cleaned up when process creation raises FileNotFoundError. Reproduce with the missing clang-tidy executable using the provided platformio.ini. Done means pio check reports the error and exits with a non-zero status instead of hanging.
Written by the indexing model from the issue text.
Description
- PlatformIO Core.
Configuration
Operating system: Linux x86-64 (Fedora), Python 3.14
PlatformIO Version (platformio --version): PlatformIO Core, version 6.2.0
Description of problem
pio check never exits when the analyser's executable is missing. It prints the
FileNotFoundError traceback and the "An unexpected error occurred" banner, and
then the process hangs until it is killed. In CI this turns a broken tool package
into a job that runs until its timeout.
Steps to Reproduce
- Create a project with
src/main.cppcontainingint main() { return 0; }and the
platformio.inibelow. - Run
pio checkonce, sotool-clangtidygets installed. - Delete
~/.platformio/packages/tool-clangtidy/clang-tidy. - Run
pio checkagain.
Actual Results
Checking repro > clangtidy (platform: native)
FileNotFoundError: Traceback (most recent call last):
File ".../platformio/check/cli.py", line 156, in cli
File ".../platformio/check/tools/base.py", line 239, in check
File ".../platformio/check/tools/base.py", line 192, in execute_check_cmd
File ".../platformio/proc.py", line 114, in exec_command
File ".../subprocess.py", line 1039, in __init__
...
FileNotFoundError: [Errno 2] No such file or directory: '~/.platformio/packages/tool-clangtidy/clang-tidy'
============================================================
An unexpected error occurred. Further steps:
...
============================================================
and the process does not exit (timeout 60 pio check ends with exit code 124).
Expected Results
pio check reports the error and exits with a non-zero status.
If problems with PlatformIO Build System:
The content of platformio.ini:
[env:repro]
platform = native
check_tool = clangtidy
Source file to reproduce issue:
int main() { return 0; }
Additional info
execute_check_cmd() passes two proc.LineBufferedAsyncPipe objects to
proc.exec_command(). Each one starts a non-daemon reader thread in its
constructor (AsyncPipeBase.__init__). In exec_command() the pipes are closed in
a finally that sits inside with subprocess.Popen(...), so when Popen itself
raises (here FileNotFoundError), the finally never runs, the reader threads stay
blocked on their pipes, and the interpreter waits for them forever at exit.
Moving the try/finally outside the with fixes it; with this change the same
reproduction exits with status 1:
try:
with subprocess.Popen(*args, **kwargs) as p:
result["out"], result["err"] = p.communicate()
result["returncode"] = p.returncode
except KeyboardInterrupt as exc:
raise exception.AbortedByUser() from exc
finally:
for s in ("stdout", "stderr"):
if isinstance(kwargs[s], AsyncPipeBase):
kwargs[s].close() # pylint: disable=no-member
The same code is in develop (platformio/proc.py, exec_command).
- Dominant language
- Python
- Stars
- 9.6k
- Forks
- 916
- PR merge metrics
- No merged PRs in 30d
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from platformio/platformio-core
-
Toolchain include order from DumpIntegrationIncludes depends on directory order (unsorted glob)Possibly taken @Leooo21 claimed this 1 day ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
platformio/platformio-core#5555 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
platformio/platformio-core#5552 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
platformio/platformio-core#5551 ·
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 48/100
platformio/platformio-core#5553 ·
Maintainers usually reply within 1 day
-
Feature suggestion: build_src_unflagsPossibly taken @hariomkhonde108 claimed this 8 days ago. Open
Difficulty 3/5 1-2 days Newbie friendliness 62/100
platformio/platformio-core#5547 · 1 comment ·
Maintainers usually reply within 1 day
All issues in platformio/platformio-core
Similar issues
-
docs(contributing): the two things that silently block a PRPossibly taken A pull request linked to this issue is open or already merged. Openavailable documentation good first issue
Difficulty 1/5 1-3 hours Newbie friendliness 95/100
Nixitov/Riptide-Native#944 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
JTHCode/secretguard#24 ·
Maintainers usually reply within 1 day
-
area: middleware documentation good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
enhancement good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Maintainers usually reply within 1 day
-
good first issue
Difficulty 1/5 Under an hour Newbie friendliness 95/100
omarelshamy25x/shamy-hijri#63 ·
Maintainers usually reply within 1 day