Troubleshooting
This page collects the failure modes that have been reproduced on real Windows, macOS, and Linux machines. It intentionally distinguishes product limitations from environment problems.
The first build takes a long time
The pinned Zig compiler builds parts of its runtime cache the first time it compiles real C or C++ code. This is normal and most visible on Windows.
Use an explicit warmup after installation:
clap bootstrap --warmupMeasured behavior from real validation machines:
- Windows Server 2022: cold first compile was roughly 50–73 seconds before warmup; after
clap bootstrap --warmup, a small project ran in about 0.47 seconds. - macOS arm64: a cold cache install plus first compile of CLAP 0.38.0 took about 20 seconds.
Warm rebuilds of small projects are normally sub-second to a few seconds depending on source size. If a build appears silent, wait for the progress output rather than assuming a deadlock; use --timing to see toolchain, compile, run, and total time.
No compiler is available
CLAP could not use the private toolchain and did not find a suitable system compiler.
Try in order:
clap doctor --probe
clap bootstrap --warmup
clap run main.c --system
clap run main.c --compiler gcc # or clang/cl/zig, if installedNotes:
- Without
--system, CLAP prefers the pinned private Zig toolchain. --offlineforbids downloading that toolchain.--compilerselects an explicit compiler executable or MSVCclwhere supported.- Corporate proxies, blocked downloads, antivirus interference, or a read-only cache directory can all break bootstrap; the underlying Zig/bootstrap error is included when available.
Zig --check is slower than a pure syntax check
Zig 0.17.1 incorrectly tries to cache an object file for -fsyntax-only even though no object is produced. CLAP therefore makes Zig --check compile each translation unit to a temporary object and deletes that object afterward. No project object file or executable is produced. This is intentionally a compile-only check, not a link, but it can cost slightly more than a true compiler syntax-only mode. GCC and Clang still use their native -fsyntax-only modes.
Coverage or sanitizers fail with Zig
This is a deliberate current limitation. The pinned Zig runtime used by CLAP does not provide the LLVM gcov/profile or sanitizer runtime pieces needed for these modes. CLAP rejects them early instead of producing misleading linker errors.
Use a system GCC or Clang toolchain:
clap run main.c --system --coverage-report coverage
clap run main.c --system --sanitize addressGCC coverage reports require gcov; Clang coverage reports require llvm-cov in PATH. Reports include .gcov files plus line/branch text, JSON, and Cobertura-style XML summaries. CI consumption examples live in COVERAGE.md. CMake test/run coverage reports use .gcno/.gcda files recursively from the CMake build tree and ignore compiler-probe files; CMake build/cmake invocations still need a subsequent test or run before report data exists.
Object cache does not hit
--object-cache is intentionally conservative. A hit requires the same compiler identity/version, language mode, normalized compile flags, relevant compile environment, source content, and the content of every compiler-reported dependency.
Common reasons for a miss:
- a project header or system header changed;
- compiler flags, language standard, target, or compiler version changed;
CPATH/language-specific include environment variables changed;- the source moved outside the project-relative dependency layout in a way that changed absolute external dependencies;
- the cache entry was evicted because
CLAP_OBJECT_CACHE_MAX_BYTESwas exceeded; - MSVC, dry-run/check, assembly, or preprocessing was used; those are outside the current scope;
- a CMake build overrode the Ninja generator, compiler selection, or compiler launcher; CLAP rejects that combination instead of guessing.
Use clap inspect to see the object-cache entry count, byte usage, and configured limit. Cache corruption is ignored rather than treated as a build failure. clap clean --cache removes cached objects and private toolchains.
Windows paths are very deep
Windows has a real operating-system process-creation limit around MAX_PATH for child-process working directories, even on machines with long-path support enabled. CLAP works around this by using a short child working directory, absolute Ninja paths, and extended executable image paths where Windows permits them.
Validated behavior: a project path over 300 characters can build, rebuild incrementally, and run when the build is launched from a short current directory.
If Windows itself refuses process creation because the current working directory is too deep, CLAP cannot override the OS. Run the command from a shorter directory and pass project paths explicitly.
Interrupting a build leaves compiler processes behind
Current CLAP terminates the controlled compiler process tree on interruption. This was validated on Windows with CTRL_C_EVENT: Zig/Ninja/Clang child processes exited and the command returned status 130.
Physical keyboard Ctrl+C behavior can still depend on the terminal, console mode, shell, and Python launcher. If a real terminal reproduces orphaned processes, report the terminal, Windows version, command, and whether --json was used.
Zero-config source discovery refuses a project
Autodiscovery is deliberately conservative. It accepts a unique root or src/ entrypoint with sibling sources, or exactly one source file. Ambiguous multi-entry projects require explicit files or clap.toml instead of guessing.
Use one of:
clap run main.c util.c[project]
sources = ["main.c", "util.c"]clap inspect shows the same source list that zero-config direct builds will use.
pkg-config itself is missing
If errors say pkg-config executable not found on PATH, adjusting PKG_CONFIG_PATH cannot help because the tool itself is absent. Install pkg-config or pkgconf with the platform package manager and restart the shell so PATH updates are visible. Debian/Ubuntu use pkg-config, Fedora uses pkgconf-pkg-config or pkgconf, macOS/Homebrew uses pkgconf, and Windows users can use a package manager such as Scoop when it provides a working executable. After installation verify pkg-config --version before retrying CLAP.
pkg-config lock validation fails
clap lock records exact resolved pkg-config versions and flags. A later build verifies that lock by default. Failure usually means the system package version changed, the package disappeared, or the lock was copied to a machine with different dependency flags.
Inspect state first:
clap deps
clap deps --jsonThen either refresh the lock intentionally:
clap lockor bypass it for one diagnosis-only build with --no-lock/--ignore-lock. Do not treat lock bypass as the normal workflow; it removes the reproducibility check.
vcpkg is configured but headers or libraries are missing
CLAP does not install vcpkg packages. It only consumes an existing vcpkg installation.
For direct builds it expects:
<vcpkg-root>/installed/<triplet>/include
<vcpkg-root>/installed/<triplet>/libor debug/lib for debug builds when present. For CMake it passes the standard vcpkg toolchain file and triplet. Install dependencies with vcpkg first, then run clap deps to inspect the resolved root/triplet state.
CMake uses the wrong compiler or generator
CLAP inspects the existing CMake cache. If compiler or generator settings conflict with the requested toolchain, it resets the CMake cache instead of silently reusing the wrong configuration. Manual --cmake-arg values remain the escape hatch for project-specific configuration.
A test report is missing or collapsed
- Direct
clap testcan run multiple independent source files and writes per-case JUnit XML. - CMake/CTest uses CTest's native
--output-junitwhen available. - If CTest cannot write that file, CLAP writes a simpler fallback report rather than silently losing the result.
Coverage across multiple independent direct test binaries is aggregated explicitly: each binary gets an isolated object directory and per-test report, while the top-level summary sums instrumented line instances. Shared headers may be counted once per test binary; the report states this instead of pretending to be a unique-line merge.
My program crashes with a Zig "panic" even though the same code "worked" elsewhere
This is the pinned Zig toolchain catching undefined behaviour that other compilers silently ignore. Zig debug builds enable safety-checked undefined-behaviour trapping by default, so an out-of-bounds index, a signed overflow, or an illegal shift aborts with the exact source line instead of corrupting memory and continuing. The same binary built with --profile release removes those checks and exhibits the silent corruption again — which is usually worse, not better.
What to do:
- Read the panic message: it names the operation and the exact
file:linein your code. That line has undefined behaviour under the C/C++ standard — the diagnostic is correct even if the program "always worked" with MSVC/GCC. - To catch the same class of bug in release builds, compile with
--sanitize undefined, which keeps the undefined-behaviour runtime instrumentation in optimized builds. - If you specifically need the non-trapping behaviour in a debug build (rare — e.g. intentional wraparound arithmetic), rewrite the operation to be standards-conforming instead of disabling the checks; e.g. use unsigned arithmetic for defined wraparound.
How to report a useful issue
Include:
clap --versionand the operating system/version;- the exact command;
- whether
--system,--offline,--compiler, CMake, vcpkg, coverage, or object cache was used; --jsonoutput when available;clap doctor --probeoutput for toolchain problems;- a minimal source tree or reproduction archive.
Do not include authentication tokens, private source code, or full corporate paths if they are sensitive.