fix(teensy): run flash in build dir + sweep stray dash-flag files (no more -r in repo root)#968
Conversation
… more `-r` in repo) ## Problem `bash autoresearch teensy41` intermittently left a 0-byte file literally named `-r` in the user's project/repo root. Reproduced: when the port auto-detects to a non-PJRC device (e.g. an ESP32 on the wrong COM port), the teensy deploy takes the `teensy_loader_cli -w` retry path, and a stray `-r` appears in the working directory during that window (~110s in). The correct-port native-flash path is clean, hence the intermittency. ## Root cause `flash::run_with_retry` spawned the loader with `cwd=None`, so it inherited the fbuild daemon's working directory — typically the user's checkout. A flag-token file (`-r`) written by a tool/shell mis-parse in that window therefore landed in the repo root. `teensy_loader_cli` itself is exonerated (its usage exposes no output-file option and it creates nothing when run with our exact argv); the fbuild subprocess/containment layer uses Windows Job Objects with no file writes. The defect is the inherited cwd. ## Fix 1. Run the flash subprocess in the firmware's own build directory (feeding the loader an ABSOLUTE firmware path so the cwd change can't break the hex read). Any artifact a flash tool leaves now lands in the gitignored build tree, never the user's checkout. 2. `sweep_stray_dash_files()` — after the flash loop, remove and WARN-log any 0-byte dash-flag file (`-r`, `-w`, …) found in the daemon cwd and the flash cwd. Guarantees the repo stays clean and logs context to attribute the intermittent writer if it ever recurs. 3. Unit test `sweep_removes_empty_dash_flag_files_only`. Reported from FastLED autoresearch teensy41 runs.
|
Warning Review limit reached
Next review available in: 26 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
#968 landed an unformatted `.map(...).unwrap_or_default()` chain in teensy/flash.rs:125, turning the repo-wide Formatting check red on main (failing for every PR since). `cargo fmt --all` reformats it; the check is green again. Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Problem
bash autoresearch teensy41(FastLED) intermittently left a 0-byte file literally named-rin the user's project/repo root.Reproduced: when the deploy port auto-detects to a non-PJRC device (e.g. an ESP32 on the wrong COM port), the teensy deploy takes the
teensy_loader_cli -wretry path, and a stray-rappears in the working directory during that window (~110 s in, caught by a filesystem poller). The correct-port native-flash path is clean — hence the intermittency.Root cause
flash::run_with_retryspawned the loader withcwd=None, so it inherited the fbuild daemon's working directory — typically the user's checkout. A flag-token file (-r) written by a tool/shell mis-parse in that window therefore landed in the repo root.Exonerated definitively:
teensy_loader_cli(its--helpexposes no output-file option; running its exact argv--mcu=… -w -v firmware.hexcreates nothing), and the fbuild subprocess/containment layer (Windows Job Objects, no file writes). The defect is the inherited cwd, not any one tool.Fix (
crates/fbuild-deploy/src/teensy/flash.rs)sweep_stray_dash_files()— after the flash loop, remove +WARN-log any 0-byte dash-flag file (-r,-w, …) found in the daemon cwd and the flash cwd. Guarantees the repo stays clean, and logs context to attribute the intermittent writer if it recurs.sweep_removes_empty_dash_flag_files_only(removes empty-r/-w; preserves non-empty-x,normal.txt, and long-verbose).soldr cargo check -p fbuild-deploypasses.Reported from FastLED autoresearch teensy41 runs.
🤖 Generated with Claude Code