Troubleshooting¶
Real error messages hit while building and fixing this template, and the exact fix. If your error is not here, read the message carefully - most of these scripts now print what went wrong and what to run next.
| Error / symptom | Cause | Fix |
|---|---|---|
fatal: Unable to create '...index.lock': File exists on a submodule |
A previous git operation was interrupted (e.g. killed mid-command) and left a stale lock file. | Make sure no git process is actually running (tasklist \| findstr git), then delete the named .lock file and retry. |
error: The following untracked working tree files would be overwritten by checkout / ...would be removed by checkout inside src/tests/googletest |
The submodule's working tree does not match its recorded commit (common after a shallow/partial clone left mismatched files). | Inside the submodule: git reset --hard HEAD && git clean -fdx, then git checkout <the pinned commit or tag>. |
git submodule update --init fails right after a fresh git clone --depth 1 --recurse-submodules |
A shallow clone cannot always reach the submodule's exact pinned commit. | Just run 0-init-submodules-windows.bat / 0-init-submodules-linux.sh - it retries automatically after fetching the submodule's full history. If you scripted this yourself: cd src/tests/googletest && git fetch --unshallow (or plain git fetch if it was not shallow), then retry git submodule update --init --recursive. |
'<script>.bat' is not recognized as an internal or external command when one script calls another (e.g. 7-build-all-windows.bat calling 6-build-and-test-windows.bat) |
On this machine, NoDefaultCurrentDirectoryInExePath=1 is set (a security hardening setting some university lab images use), which disables the normal "search the current directory" step for a bare command name, even right after cd-ing into that directory. |
All cross-script calls in this template now use the full path, call "%~dp0other-script.bat", which does not depend on that setting. If you add your own script that calls another one, do the same. |
Doxygen prints error: PLANTUML_JAR_PATH is not a directory with a 'plantuml.jar' file... |
4-install-tools-windows.bat was not run, so plantuml.jar does not exist, but the Doxyfile pointed straight at that (missing) file. |
Fixed: config/Doxyfile-lib and config/Doxyfile-tests now read PLANTUML_JAR_PATH from an (optional) environment variable; with it unset (the default), Doxygen simply skips PlantUML diagrams, no error. Run 4-install-tools-windows.bat once if you actually want PlantUML diagrams rendered. |
cmake -G "Visual Studio 17 2022" fails, or picks the wrong compiler |
The generator was hard-coded to one specific Visual Studio version, which is not installed on every machine (e.g. a lab machine with only Ninja + MinGW). | Fixed: scripts\detect-generator-windows.bat looks up the installed Visual Studio with vswhere.exe and uses the matching generator, or falls back to Ninja + gcc/g++ if no Visual Studio is found. |
python -m coverxygen fails with No module named coverxygen, even though you already ran pip install for it |
A different python was found first on PATH than the one you installed the package into (this template's own author hit this: python resolved to a Python 2.7 bundled with an unrelated graphics application). |
Fixed: scripts\detect-python-windows.bat probes py -3, python3, then python, and uses whichever actually has coverxygen importable, printing the exact pip install command to run if none do. If you run coverxygen by hand, use py -3 -m coverxygen ... (or check with py -3 -m pip show coverxygen). |
'genhtml' is not recognized as an internal or external command even though where genhtml finds it |
genhtml (from lcov) is a Perl script with no file extension; cmd.exe cannot execute a bare extension-less file directly, only via its interpreter. |
Fixed: scripts\detect-genhtml-windows.bat finds both genhtml and perl and runs perl "<path-to-genhtml>" ...; if either is missing it skips just that one native report with a warning instead of failing the whole build. |
A cmd.exe batch script aborts mid-run with ... was unexpected at this time. |
A literal, unquoted ( or ) inside an echo line that is itself inside an if ... ( ... ) block confuses cmd's block parser (it tries to match it as a nested block). Quoted parentheses, e.g. inside "-title:... (Windows)", are fine - cmd's parser is quote-aware for those. |
Escape literal, unquoted parentheses as ^( / ^), or rephrase to avoid them (e.g. "regenerated" instead of "(re)generated"). |
wsl: Failed to translate 'G:\My Drive\...' |
WSL cannot resolve a path under a Google-Drive-synced Windows folder at all. | Copy the repository to a path under WSL's own filesystem (e.g. ~/work/...) or any local C:\... path, and run the .sh scripts from there - see install. |
geninfo: WARNING: GCOV did not produce any data for ...gcno, then lcov: ERROR: no valid records found in tracefile |
The gcc/g++ used to compile and the gcov used to read the coverage data are different major versions (a distro can have several installed side by side, e.g. gcc-7, gcc-9, gcc-13, with gcov symlinked via update-alternatives to a different one than the default gcc). |
Fixed: 7-build-all-linux.sh picks a matching GCC/gcov pair (preferring the newest available) and uses cmake -DCMAKE_C_COMPILER=... -DCMAKE_CXX_COMPILER=... and lcov --gcov-tool ... consistently. If you invoke gcov/lcov by hand, check that gcc --version and gcov --version agree first. |
reportgenerator prints The specified framework 'Microsoft.NETCore.App', version 'X.0.0' was not found. ... found 3.1.32 |
The system's dotnet is a very old distro-packaged one (e.g. Ubuntu 20.04's apt dotnet-sdk is .NET 3.1), but the current dotnet-reportgenerator-globaltool needs a current .NET runtime. |
Fixed: 4-install-tools-linux.sh now installs a per-user, current .NET SDK via the official dotnet-install.sh into ~/.dotnet and puts it ahead of the system one on PATH (added to ~/.bashrc). Open a new shell (or source ~/.bashrc) after running it. |
lcov --capture (or gcovr) hangs indefinitely (a gcov-N process alive but barely using CPU, ps shows a large but static virtual memory size), while the same, correctly-versioned gcov run directly on the same .gcda/.gcno file usually finishes in well under a second |
Reproduced repeatedly on WSL2 Ubuntu 20.04 with lcov 1.14 (the apt-packaged version) and gcovr: gcov's output, piped through another process (lcov's Perl geninfo driver, or gcovr's Python subprocess handling) rather than to a terminal/file, occasionally deadlocks on WSL2 for this exact gcov invocation shape (--branch-counts --branch-probabilities --demangled-names --hash-filenames --object-directory ...). It is not reliably tied to file size (it hit both a large file, googletest's own amalgamated gtest-all.cc.gcda, and small ones, e.g. calculatorapp.cpp.gcda, on different runs) and is not fully deterministic (the same command can succeed on one run and hang on the next) - this looks like a WSL2-specific pipe/scheduling issue rather than a straightforward lcov or gcovr bug. setarch "$(uname -m)" -R <command> (disables ASLR) is worth trying first, and is used automatically when available, but did not reliably prevent it on the test machine. |
Fixed defensively, since the hang cannot be reliably prevented: 7-build-all-linux.sh runs both lcov --capture and gcovr under a timeout (180s each); on a timeout, that run's affected report(s) are skipped with a clear warning instead of hanging the whole build forever, and every other step (build, test, Doxygen, coverxygen, ReportGenerator's documentation-coverage report, mkdocs) still completes. gcovr is also told to skip googletest's own build artifacts entirely (--gcov-exclude/--exclude-directories '.*/googletest.*'), which removes the largest single source of this and is a straightforward win regardless of the deeper issue. If you hit this often: try a non-WSL Linux machine or VM for the coverage step, or a current lcov (2.x) instead of an old distro-packaged 1.14 (https://github.com/linux-test-project/lcov). |
Native genhtml doc-coverage report is missing an annotated view for README.md specifically, with genhtml: ERROR: cannot read .../README.md in the log, while the actual C++ source files render fine |
genhtml computes one common path prefix from all files in the .info file to shorten displayed paths; README.md sits one directory above that computed prefix (everything else is under src/), which confuses its per-file path reconstruction for that one outlier file. This is a genhtml limitation, not a build failure - the rest of the report (all real source files) is unaffected, and it does not stop the build. |
Fixed: 7-build-all-* runs coverxygen with --exclude '.*\.md$', so Markdown files (the README is Doxygen's main page, not code) are not part of the documentation-coverage data any more and genhtml gets only source files. If you see it in your own project, exclude the odd file the same way. |
A Google-Drive-synced repository shows Git warnings like warning: ignoring broken ref refs/heads/desktop.ini |
Google Drive for Desktop periodically writes its own desktop.ini customization files everywhere, including inside .git/, .git/refs/heads/, etc., where Git tries (and fails) to interpret them as refs. |
Harmless; the repository's own maintenance scripts already clean these up (scripts\delete-desktop-ini-windows.bat / scripts/delete-desktop-ini-linux.sh, called by 0-init-submodules-* and the pre-commit hook). Re-run one of those if you see this. |
mkdocs build prints WARNING - A reference to '....md' is included in the 'nav' configuration, which is not found in the documentation files. |
A stale entry in mkdocs.yml's nav, or a report page under docs/reports/<platform>/ that was not generated (a new entry in tools/report_catalog.py needs python3 tools/gen_report_pages.py). |
Fix or remove the nav entry; run python3 tools/gen_report_pages.py. The pages are committed, so a fresh clone always has them - the reports themselves (reports/<platform>/...) only exist for the platform you built, and the site shows a short note instead of an empty frame for the other one. See reports-in-site. |
A GitHub Actions workflow YAML fails to parse with yaml.scanner.ScannerError: mapping values are not allowed here (or an editor shows "Nested mappings are not allowed in compact mappings") pointing at a - name: ... line |
An unquoted YAML scalar that contains : (colon + space) - e.g. - name: Checkout (sources: docs/index.md) - gets parsed as the start of a nested mapping, not as plain text, because : followed by a space is YAML's own key/value separator. Hit for real while writing .github/workflows/pages.yml/release.yml in this project. |
Quote the whole value: - name: "Checkout (sources - docs/index.md)", or avoid the colon (use - or ; instead). Validate every workflow file before pushing: python -c "import yaml; yaml.safe_load(open('.github/workflows/X.yml'))". |
A .bat script fails with '<script>.bat' is not recognized as an internal or external command even when run directly from an already-open terminal in that folder (not just when one script calls another - see the entry below for that case) |
Same root cause as the script-calling-script case: NoDefaultCurrentDirectoryInExePath=1 disables "search the current directory for a bare filename" even though you cd'd there first. |
Always invoke with an explicit path: .\7-build-all-windows.bat (relative) or the full path, never a bare 7-build-all-windows.bat. This template's own scripts avoid the problem internally by starting with @cd /d "%~dp0" and using call "%~dp0other-script.bat" for every cross-script call - see the next row. |
Chocolatey (choco install/choco upgrade) fails with Access to the path 'C:\ProgramData\chocolatey\...' is denied |
Chocolatey's default install location (C:\ProgramData\chocolatey) is machine-wide and needs Administrator rights; the terminal/script was not elevated. |
Run the terminal (or 4-install-tools-windows.bat) as Administrator - right-click -> "Run as administrator", or launch an elevated terminal first. |
CMake Error at ...GoogleTestAddTests.cmake ... Error running test executable ... Result: Process terminated due to timeout while building a test target |
gtest_discover_tests runs the freshly linked test executable at build time with a 5 s default timeout; the first run of a new .exe can be slower than that (antivirus scanning it). |
Fixed: src/tests/*/CMakeLists.txt use gtest_discover_tests(... DISCOVERY_TIMEOUT 60). If you add a test target, pass the same option. |
fatal: git upload-pack: not our ref 0000000000000000000000000000000000000000 when cloning a Google-Drive-synced repository |
Google Drive put desktop.ini files inside .git/refs/, and the clone source now has broken refs. |
Delete them first: find .git -name desktop.ini -delete (or del /S /A:H .git\desktop.ini), then clone again. |
CMake Warning: Manually-specified variables were not used by the project: CMAKE_BUILD_TYPE |
A multi-config generator (Visual Studio) ignores CMAKE_BUILD_TYPE. |
Fixed: 6-build-and-test-windows.bat passes it only to single-config generators (Ninja); Visual Studio gets --config Debug or --config Release at build time. |
project.env: PROJECT_NAME is not set / load-project-env: ERROR |
project.env is missing, has spaces around =, or is not in the repository root. |
Format is KEY=value, one per line, no spaces, no quotes. Restore it from git: git checkout project.env. |
genhtml: ERROR: cannot create directory 'reports\windows\doccoverage-lcov\lib'! |
genhtml on Windows does not create nested output folders. |
Fixed: 7-build-all-windows.bat creates the parent folder first. If you add your own genhtml step, mkdir the parent yourself. |
Site check prints ERROR: n BROKEN link(s) inside our own pages |
A link in one of the docs/ pages points to a file that is not in the built site (a renamed page, a badge path). |
The list names the page and the link: fix the link. Links into another platform's report that was not built here are skipped or only warned about locally; CI (--strict-reports) has both platforms and fails on them. |
| The report page shows "This report is not part of this build of the site" | You built only one platform locally. | Expected: Windows builds Windows reports, Linux builds Linux reports; CI builds both. Build on the other platform (or WSL) to see them. |
10-release-* says the current commit is not pushed yet / the working tree is not clean |
A release must come from a pushed, committed state. | git status, commit, git push, run again. --dry-run skips these checks. |
Every report page is a blank frame when you double-click site/index.html |
Browsers block <iframe>s on file:// pages. |
Use 9-open-site-windows.bat / ./9-open-site-linux.sh (serves http://localhost:8000/). |
General checklist when something in a script fails¶
- Read the last ~10 lines of output before the failure - these scripts print what step they were on
(
echo ...) right before each major command. - Re-run just that one tool by hand with the same arguments shown in the script, to see its full error output (the script may have truncated or redirected it).
- Check
docs/guide/install.en.md- is the specific tool actually installed and the right version on PATH? 11-clean-windows.bat/./11-clean-linux.sh(see daily-workflow), then retry from a clean state - some failures are caused by stale output from a previous run with different settings.
Other things to watch for (general, did not necessarily happen on this machine)¶
- Long paths on Windows: if you clone very deep (e.g. inside several nested folders), some tools
can hit the ~260 character path limit. Clone closer to a drive root, or enable long paths
(
git config --system core.longpaths trueand the Windows 10+ "Enable Win32 long paths" group policy). - Antivirus locking files: if a build step fails with a file "in use by another process" right
after a previous step wrote it, antivirus real-time scanning is a common cause - exclude the
repository's
build/,publish/,reports/andrelease/folders if this happens repeatedly. - Port already in use: this template does not run a server itself; if you add one for your own
project topic and hit
Address already in use, find and stop the other process (netstat -ano | findstr :<port>on Windows,lsof -i :<port>on Linux) rather than picking a random different port every time (keep it documented and consistent).