#3998·Nuitka

`enableCcache` overwrites a user-set `CCACHE_SLOPPINESS`, unlike `CCACHE_DIR` which is honored

Author: kdeldyckeCreated Aug 12, 2026Updated Sep 30, 2026
Labelsbughelp wanteddevelopexcellent_report

Bug Description

enableCcache() in nuitka/build/SconsCaching.py sets CCACHE_SLOPPINESS unconditionally, overwriting any value the user exported. The neighboring CCACHE_DIR handling in the same function is guarded (if "CCACHE_DIR" not in os.environ:), so a user-chosen cache directory is honored, but a user-chosen sloppiness is silently replaced, and because environment variables outrank ccache.conf, a value written there is overridden too.

The practical consequence: settings like time_macros (needed when compiled sources touch __DATE__/__TIME__/__TIMESTAMP__) or any CI-specific sloppiness cannot be applied by the user at all, and there is no error or warning: ccache simply runs with Nuitka's include_file_ctime,include_file_mtime and nothing else. I lost a debugging round to this: the ccache debug log was the only place revealing that my exported value never reached the compiler wrapper.

https://github.com/Nuitka/Nuitka/blob/95b12dd9ae354e83bf1807bfe017e78b46ba57a0/nuitka/build/SconsCaching.py#L180-L183

️ Environment

1. Nuitka Version, Python Version, OS, and Platform

4.1.3
Commercial: None
Python: 3.14.6 (main, Jul 23 2026, 14:49:22) [Clang 22.1.3 ]
Flavor: Python Build Standalone
GIL: yes
Executable: .venv/bin/python
OS: Darwin
Arch: x86_64
macOSRelease: 26.6.1
Version C compiler: clang (clang 21.0.0).

2. How Nuitka and Python were Installed

Installed from PyPI (uvx nuitka==4.1.3, equivalent to pip install nuitka==4.1.3) into a virtualenv.

3. Relevant PyPI Packages and Versions

Not applicable: no third-party package is involved.

️ To Reproduce

1. "Hello World" Test (if applicable)

Compilation succeeds; the issue is configuration handling.

2. Short, Self-Contained, Correct, Eligible (SSCCE) Example

python
# hello.py
print("hello world")

3. Nuitka Command Line Options

bash
export CCACHE_SLOPPINESS=time_macros
python -m nuitka --mode=onefile --assume-yes-for-downloads hello.py

Then inspect the ccache log (the file CCACHE_LOGFILE points at in the build directory).

Expected Behavior

A pre-set CCACHE_SLOPPINESS is honored the way a pre-set CCACHE_DIR already is: either skip the assignment when the variable exists (same guard as CCACHE_DIR), or merge Nuitka's include_file_ctime,include_file_mtime into the user's list, since the two are complementary rather than conflicting.

Actual Behavior & Output

The user's value is replaced. ccache's own log shows the effective configuration with Nuitka's value, and the exported time_macros is gone:

Config: (environment) sloppiness = include_file_mtime, include_file_ctime

↩️ Regression (if applicable)

Not a regression as far as I can trace.

Additional Context (Optional)

Found while diagnosing a cross-machine cache-miss problem in CI, where the overwrite cost one full hypothesis-test cycle before the ccache log revealed it. A merge (user value + Nuitka's two include_file entries) seems strictly better than either value alone; if a PR doing that, or simply mirroring the CCACHE_DIR guard, would be welcome, I am happy to send it.

Relates to: