Skip to content

Log a diagnostic when a filepath approaches or exceeds its platform's practical length limit - #1207

Merged
mkarlesky merged 4 commits into
next_versionfrom
feature/filepath-length-checks-next-version
Aug 14, 2026
Merged

Log a diagnostic when a filepath approaches or exceeds its platform's practical length limit#1207
mkarlesky merged 4 commits into
next_versionfrom
feature/filepath-length-checks-next-version

Conversation

@mkarlesky

Copy link
Copy Markdown
Member

Summary

  • FileWrapper now checks path length on every mutating file operation (mkdir, mkdir_tmp, cp, write, write_blank_file, write-mode open), logging a WARNING as a path approaches its platform's practical length ceiling and an ERROR once it reaches or exceeds it. Diagnostic only — never blocks the operation itself.
  • FilePathUtils#form_named_path/#form_build_context_path, the two shared builders nearly all generated build paths funnel through, get the same check.
  • Added SystemWrapper.macos?, mirroring the existing windows? pattern, so the platform-specific limit (Windows 260 / macOS 1024 / Linux 4096) can be selected.
  • Routed the six remaining raw File.open/File.read/File.write call sites (ErbWrapper, YamlWrapper, PreprocessinatorLineMarkerIncludesExtractor, PreprocessinatorCommentStripper, PreprocessinatorCodeFinder, CExtractor) through FileWrapper so the check is genuinely singular rather than partial.
  • Resolved the resulting LoginatorFileWrapper circular dependency by moving Loginator's own logfile write onto raw File I/O (it's the one place in the codebase that can't route through FileWrapper, since FileWrapper's own diagnostics log through Loginator).

Test plan

  • Full unit suite: 2470 examples, 0 failures, 1 pre-existing pending
  • New unit coverage for FileWrapper#check_path_length (threshold math, origin-prefix gating, platform-limit selection) and SystemWrapper.macos?
  • Manual end-to-end verification against a real hand-built project with a deliberately long build path: WARNING/ERROR fire correctly at both default and --verbosity=debug (origin prefix present only at DEBUG), normal-length paths produce no false positives, and the build/test run completes and passes throughout

mkarlesky and others added 4 commits August 13, 2026 23:44
… practical length limit

Deep project subdirectories (especially under CI) can silently exceed Windows'
260-char MAX_PATH and similar OS/libc ceilings, producing mysterious build
failures far from their root cause. FileWrapper now checks path length on
every mutating file operation, and FilePathUtils checks the two shared
builders nearly all generated build paths funnel through, logging a WARNING
as a path approaches the limit and an ERROR once it reaches or exceeds it --
diagnostic only, never blocking the operation itself.

Making this check genuinely singular (rather than partial) required routing
the six remaining raw File.open/File.read/File.write call sites through
FileWrapper, and moving Loginator off FileWrapper (onto raw File I/O for its
own logfile) to break the circular dependency that introduced.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…nstructor args

spec_system_helper.rb required ceedling/yaml_wrapper before spec_helper (which
loads the 'constructor' gem), so YamlWrapper's new `constructor :file_wrapper`
call blew up at load time -- reordered the requires. That in turn surfaced
every YamlWrapper.new/FileWrapper.new call site across the system-spec support
files that predates this feature and never supplied the now-required
dependencies; updated each to match the pattern already established in
dependency_tracker_system_helper.rb (real collaborators where behavior is
actually exercised, null objects otherwise). SystemContext is a plain
standalone class rather than an RSpec-included module, so `double` isn't
reachable from its instance methods -- used a trivial NullLoginator and a
real Verbosinator there instead.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
path_of_length(n) assumed File.expand_path('/some/path').length == the raw
string's own length, true on POSIX but not on Windows, where expand_path
prepends a drive letter (e.g. "/aaa" -> "C:/aaa") -- two extra characters
that pushed the 95%-threshold boundary test across the line on Windows CI.
Size the padding off File.expand_path('/')'s own actual length instead of
assuming it's 1, so the helper produces the intended expanded length on
any platform.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@mkarlesky
mkarlesky merged commit 1d36c95 into next_version Aug 14, 2026
20 checks passed
@mkarlesky
mkarlesky deleted the feature/filepath-length-checks-next-version branch August 14, 2026 05:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant