Skip to content

bash compile leaves an empty file named -r in the repo root #3867

Closed

Description

@zackees

Reproducer

$ rm -f -- ./-r
$ bash compile teensy41 --examples Blink >/dev/null 2>&1
$ ls -la -- ./-r
-rw-r--r-- 1 ... 0 Aug  6 12:56 ./-r

Reproduced repeatedly on master at ccbdc9de34 (Windows 10, Git Bash). The file is always empty (0 bytes) and lands in the repo root.

Why it matters

It shows up as untracked in git status, so every bash compile dirties a clean working tree. That's noise for anyone (or any agent) whose workflow asserts a clean tree before committing, and the leading - makes it awkward to delete — rm ./-r or rm -- -r is required, plain rm -r is a very different command.

What I ruled out

A quick pass did not find the culprit:

  • ci/util/create_build_dir.py:148 — subprocess.run(["attrib", "-r", path]) is a list (no shell) and only runs from the rmtree readonly handler, which a clean compile shouldn't hit.
  • ci/lint/stage_impls.py:207,213 — ["uv", "run", "ci/run-clang-format.py", "-i", "-r", folder] is also a list, no shell.
  • ci/run-clang-format.py:287 — that -r is an argparse option definition.

Likely a shell=True invocation somewhere in the compile path where a -r argument gets separated from its command, or a stray redirect. ci/util/create_build_dir.py and ci/util/pio_runner.py both build command strings with list2cmdline + shell=True, which would be the place to look first.

I hit this while working on #3864 and did not chase it further, since it is unrelated to that issue. Filing so it is tracked rather than repeatedly deleted by hand.

Acceptance criteria

  • bash compile <board> --examples <ex> leaves the working tree clean.
  • The offending invocation is fixed at the source rather than by adding -r to .gitignore.

Activity

  1. zackees commented on Aug 7, 2026

    @zackees
    MemberAuthor

    Investigated — root cause is not in FastLED. Tracked upstream as FastLED/fbuild#1267.

    I reproduced this deterministically and narrowed it by elimination. Summary of the bisection:

    # Test -r created? Conclusion
    1 bash compile teensy41 --examples Blink (repeat, no-op rebuild) no trigger needs a build that does real work — this initially produced false negatives
    2 bash compile teensy41 --examples Audio (example switch → real work) yes reproducible trigger found
    3 uv run ci/ci-compile.py … (bypass the bash compile wrapper) yes not the shell wrapper
    4 audit-hook trace of ci-compile.py — stack at creation: ci/util/fbuild_runner.py:397 → RunningProcess.wait(), i.e. FastLED was merely waiting on the fbuild child. Only one in-process spawn all run (pio platform show), and no open() of -r. So no FastLED code writes it.
    5 fbuild.exe … build -e teensy41 -c directly, without venv Scripts on PATH no —
    6 same, with venv Scripts on PATH yes the difference is fbuild_subprocess_env() prepending the venv, which lets fbuild resolve zccache helpers
    7 PATH containing only zccache*.exe yes isolated to zccache binaries
    8 PATH containing only zccache.exe + zccache-daemon.exe (withhold zccache-fp.exe) no (verified twice, 45.9s real work) zccache-fp on PATH is the gate
    9 fbuild run from a scratch CWD yes, in the scratch dir the file is CWD-relative, nothing to do with this repo

    So: plain fbuild.exe, run from any directory, with zccache-fp on PATH, drops a 0-byte -r in the CWD on a clean build. No FastLED code is involved — FastLED just happens to invoke fbuild with CWD = repo root.

    Additional characterisation:

    • Created during the Linking firmware.elf stage (caught with a 20 ms watcher snapshotting the verbose log at that instant).
    • Pre-creating a directory named -r blocks the write and the build still succeeds with no diagnostic — the error is silently swallowed.
    • Direct zccache-fp invocations (check, check --root ., check -r ., mark-success) do not create it, and zccache-fp check has no -r short flag, so this doesn't look like zccache-fp writing it unprompted.
    • fbuild embeds zccache fingerprint code (embedded fingerprint check failed for, .zccache_fp.json, stamp_cache.json; the build dir gets .project.zccache_fp.stamp_cache.json), gated on zccache-fp being present.

    Two corrections to my original report

    1. My original "What I ruled out" section pointed at create_build_dir.py / pio_runner.py shell=True call sites. That was the wrong tree entirely — no FastLED Python writes this file.
    2. During the bisection I briefly concluded the file was not CWD-relative. That was a false negative from a no-op build; re-running with timings visible showed it is CWD-relative. Worth flagging because this bug produces false negatives very easily — any verification must confirm the build actually did work (-c, and check the elapsed time).

    Why there is no FastLED PR

    Environment versions: fbuild 2.5.14, zccache 1.13.0.

    The two FastLED-side "fixes" available are both wrong:

    • Adding -r to .gitignore — explicitly ruled out by this issue's own acceptance criteria, and it would hide the bug rather than fix it.
    • Changing fbuild_subprocess_env() to stop prepending the venv Scripts dir — that prepend exists deliberately (infra(windows): zccache daemon balloons + locks; PATH-version mismatch breaks fbuild builds #2853) to stop a stray global zccache.exe causing cross-version daemon corruption. Removing it to dodge this would trade a cosmetic stray file for a real correctness hazard.

    Closing here and tracking at FastLED/fbuild#1267, which carries the minimal reproduction. Reopen if it turns out FastLED is provoking it after all.

  2. zackees commented on Aug 7, 2026

    @zackees
    MemberAuthor

    Closing as not a FastLED bug — root cause is in fbuild/zccache, tracked with a minimal reproduction at FastLED/fbuild#1267. See the investigation above for the full bisection.

  3. zackees commented on Aug 7, 2026

    @zackees
    MemberAuthor

    Reopening briefly to correct the record and close this properly — the earlier "not planned / no fix available" conclusion was wrong. A fix has now landed.

  4. reopened this on Aug 7, 2026
  5. zackees commented on Aug 7, 2026

    @zackees
    MemberAuthor

    Fixed upstream — FastLED/fbuild#1268 (merged, 0dd68b24)

    Root cause

    crates/fbuild-build-arm/src/teensy/teensy_linker.rs passed None as the working directory to run_command, on both the response-file and direct-args branches. So arm-none-eabi-gcc — and the collect2 / lto-wrapper processes it hands off to under -flto=auto -fuse-linker-plugin — ran in whatever cwd the fbuild daemon inherited, normally the user's project root. Those helpers write scratch files relative to the process cwd, and one of them is the 0-byte -r.

    fbuild had already fixed this exact thing for the teensy deploy path; sweep_stray_dash_files' neighbouring comment states the remedy outright: "Run the loader in the firmware's own build directory rather than inheriting the daemon's working directory (which is typically the user's project/repo root)." The build path never got the same treatment. It also completes fbuild#261, which redirected the env-based LTO temp dir but left cwd inherited.

    The fix passes the output directory as the link cwd, guarded on is_absolute() so a relative output_dir keeps the old behaviour (moving cwd would otherwise relocate the relative -o).

    Verification

    Same machine, same environment, real teensy41 clean build:

    build repo root
    fbuild 2.5.14 (control) succeeded in 37.7s ./-r CREATED
    with the fix succeeded in 46.4s clean — stray now at .fbuild/build/release/-r, inside the gitignored tree

    Byte-identical artifacts both ways (flash 72704, RAM 81984), so it is purely a relocation of where linker scratch files land. soldr cargo test -p fbuild-build-arm --lib → 204 passed, including two new tests.

    Corrections to my earlier comments on this issue

    1. "zccache-fp on PATH is the gate" was wrong. It reproduced with all three zccache binaries present and not twice without zccache-fp.exe, so I called it causal. It was coincidence — this bug is intermittent, which sweep_stray_dash_files' own comment already said. zccache is not involved at all. I've corrected fbuild#1267 too.
    2. "There is no FastLED PR that can fix this, closing as not-planned" was premature. Correct that the fix didn't belong in FastLED — but I stopped at "not our bug" instead of going upstream and fixing it. The fix was a two-line change in a repo I could reach.
    3. The original report's "what I ruled out" section blamed create_build_dir.py / pio_runner.py shell=True sites. Wrong tree entirely — no FastLED Python ever wrote this file.

    Getting the fix

    0dd68b24 is on fbuild main but not yet released; FastLED pins fbuild==2.5.14. It arrives here when a release containing it is cut and the pin is bumped — the same gate as fbuild#1263 (see #3864). Until then bash compile will keep dropping the file; remove it with rm -- ./-r, never plain rm -r.

    Also fixed along the way: #3868, because the gh pr merge review guard blocked merging the upstream PR by inspecting this checkout's branch instead of the PR being merged.

    Closing as completed.

  6. moved this from Done to Triage in FastLED Trackeron Aug 7, 2026
  7. moved this from Triage to Done in FastLED Trackeron Aug 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions