bazel coverage produces empty coverage analysis reports and a message about missing GCov when running against a py_test target
π bug report
Affected Rule
The issue is caused by the rule: py_test()Is this a regression?
NoDescription
After the successful execution of the bazel test command I attempted to add the coverage tool too.Unfortunately, I get output:
GCov does not exist at the given path: '' Oct 13, 2025 12:50:34 PM com.google.devtools.coverageoutputgenerator.Main runWithArgs WARNING: There was no coverage found.
I want to use the coverage (opensource) pip package for gathering coverage data of Python tests. I have no clue why running bazelisk coverage --combined_report=lcov //... --test_output=all returns that GCov does not exist.
My test scripts are written with unittest framework, and they successfully run with bazelisk test :all --test_output=all
π¬ Minimal Reproduction
https://github.com/TeodorMalbasic/bazel_coverage_target_issue.git
π₯ Exception or Error
GCov does not exist at the given path: ''
Oct 13, 2025 12:50:34 PM com.google.devtools.coverageoutputgenerator.Main runWithArgs
WARNING: There was no coverage found.
π Your Environment
Operating System:
Ubuntu 24.04
Output of bazel version:
bazel 8.4.2
Rules_python version:
Python 3.12.3 on machine, Python 3.12.11 in MODULE.bazel
Anything else relevant?
Could you please share your repo so that I can look at the repro please?
@aignas shared
I am not sure if you should include the coverage dependency in the test - the toolchain will include it automatically if you specify the extra flag when configuring it in your MODULE.bazel file. Maybe this is related to that. As it is the repro does not have any python files, so I cannot verify if this is correct.
It should be OK to include coverage in deps manually. All the bootstrap does is import coverage so it shouldn't be particular about where it comes from.
That said, don't we apply some patches to the coverage bundled with the toolchain? It could be the user space coverage is being used, but without that patches, something goes awry.
@aignas originally, the solution was without coverage as dependency. I had the same output of GCov not existing.
Ah, is it not the case that you need to install gcov on your host to be able to run the bazel coverage command? rules_python is not doing anything here and searching the code of bazel itself seems to suggest that this may be the case: https://github.com/search?q=repo%3Abazelbuild%2Fbazel+GCov&type=code&p=1
I am inclined to close this as won't do because it is out of scope for rules_python.
@aignas If I understood correctly, action from my side would be to install gcov on my host machine? If so, is there any specific version (or range of versions) of gcov that I need to install?
I'm having the same issue for Python coverage, but C++ coverage works fine.
@aignas I checked if I have gcov installed, and I do. After running gcov --version, output is: gcov (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0 Copyright (C) 2023 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Anyway, If I need to open a new ticket somewhere else, please point me to the right direction, since I'm just starting with using Bazel, I don't yet know my way around. Thank you in advance!
Hello @aignas, Is it possible to transfer the ticket if it is out of scope for this repository?