Skip to content

build(meson): bash test --cpp fails inside .claude/worktrees/ worktrees (Windows path / object-name encoding) #2887

Closed

Description

@zackees

Symptom

Running bash test --cpp from inside a worktree created under .claude/worktrees/<branch>/ fails reproducibly with errors like:

[9/677] Compiling C++ object ci/meson/native/libcrash_handler.a.p/C__Users_niteris_dev_fastled10_.claude_worktrees_<branch>_tests_shared_crash_handler_main.cpp.obj
error: unable to open output file 'ci/meson/native/libcrash_handler.a.p/C__Users_niteris_dev_fastled10_.claude_worktrees_<branch>_tests_shared_crash_handler_main.cpp.obj': 'no such file or directory'

The same checkout from the main working tree at C:\Users\niteris\dev\fastled10\ builds clean — 310/310 tests pass.

Root cause hypothesis

Meson encodes the full absolute source path into the object filename (e.g. C__Users_niteris_dev_fastled10_.claude_worktrees_<branch>_tests_shared_crash_handler_main.cpp.obj). When the worktree path lives under .claude/worktrees/<branch>/ the encoded name can exceed Windows long-path limits or hit a meson/ninja parent-dir-creation race, leaving the libcrash_handler.a.p/ subdirectory present but the object file unwritable.

The directory IS created (it can be ls'd after the failure), it's just empty. So meson allocated the path but clang couldn't open the output for write — typical "path too long" or "permission denied due to junction" symptom on Windows.

Reproduction

git fetch origin master
git worktree add -b repro-meson-worktree .claude/worktrees/meson-bug origin/master
cd .claude/worktrees/meson-bug
bash test --cpp
# → fails with the message above

(Tested with worktree branch names of 11-30 chars. The exact failure point depends on which TU clang reaches first.)

Impact

  • clud-pr workflow is broken inside worktrees: bash test --cpp is the canonical gate, and it cannot validate from the disposable worktree the workflow mandates.
  • Forces agents to copy the entire .build/ tree from the main checkout into the worktree (which is itself stale because meson configure baked-in paths from the original checkout), defeating the worktree isolation point.

Workarounds tried (all fail)

  1. bash test --cpp --clean — .build/meson-quick gets wiped, same error on rebuild.
  2. Force-clearing .build/ via the override hook — same.
  3. Build from main checkout, copy .build/ to worktree — paths inside meson's compile_commands.json point at the main checkout, lint passes but the build is semantically meaningless.

Suggested fix paths (pick one)

  1. Shorten the object-file encoding — pass -Db_obj_basename=short (if supported) or set a meson.options to use hashed object names instead of path-encoded ones.
  2. Move worktrees to a sibling path — agents create ../<repo>-wt-<branch>/ outside the repo. Removes the path-length amplification. The clud-pr skill already allows this as a fallback.
  3. Enable Windows long-path support in the project's git config core.longpaths true + a ci/hooks/setup_long_paths.py helper. Doesn't help non-Windows but it's a one-line setup.

Related

  • The clud-pr workflow that creates the failing worktrees: .claude/skills/clud-pr/SKILL.md
  • agents/docs/binary-size-analysis.md — bash bloat works from worktrees because it only reads pre-built ELFs (no meson compile), so it's not impacted; only the test-build path is.

🤖 Filed via Claude Code after hitting this during a printf-family-ban PR.

Activity

  1. zackees commented on Jul 27, 2026

    @zackees
    MemberAuthor

    Root-cause hypothesis confirmed and quantified — it is the MAX_PATH limit, and the trigger is worktree-path length, which is why it looked intermittent.

    Measurement

    Computed the encoded object path for every real source (330 .cpp files under tests/ and src/, build/artifact dirs excluded) as it would appear under .claude/worktrees/<branch>/:

    worktree branch name longest object path files over 260
    wt (2 chars) 250 0
    meson-bug (9 chars) 264 1
    fix/some-descriptive-branch (26 chars) 300 34

    Longest offender is consistently tests/platforms/arm/teensy/teensy4_common/drivers/objectfled/channel_engine_objectfled.cpp.

    That explains every observed symptom: the main worktree at C:\Users\niteris\dev\fastled\ has a short enough prefix to stay under the limit, the .claude/worktrees/<branch>/ prefix adds ~30+ chars, and "which TU clang reaches first" varies because only the tail of the length distribution crosses 260. It also matches the report that branch names of 11-30 chars were the ones that broke.

    Why the paths are that long

    Meson encodes the absolute source path into the object filename because the sources are handed to it as absolute strings — tests/meson.build builds them as path_norm_root + '/tests/' + test_file (lines 183-185, 202), where path_norm_root = meson.project_source_root().

    So each object name carries the full C__Users_niteris_dev_fastled_.claude_worktrees_<branch>_ prefix on top of the already-deep tests/platforms/arm/teensy/... path.

    Why the obvious fix needs care

    Passing sources as paths relative to tests/meson.build would cut the encoded name down to platforms_arm_teensy_..._channel_engine_objectfled.cpp.obj and fix this outright. But two things in this exact code path have already been root-caused as bugs, so it should not be a drive-by change:

    1. The absolute forward-slash convention is itself a fix. ci/meson/shared/meson.build:37-53 documents it at length: meson's / join operator emits a native backslash mid-path on Windows, which produced mixed separators, which defeated #pragma once dedup, which surfaced as error: redefinition of 'LogLevel' — reproduced and root-caused 2026-06-02 after fix(io): finish fl::print minimal-surface contract for hosts (closes #2668) #2683/chore(lint): clear pre-existing bash-lint baseline failures #2684. The -I flags must stay absolute regardless of what happens to source paths.

    2. __FILE__ changes. Test sources' __FILE__ currently expands to the absolute path, and FL_TEST_FILE_FILTER matches against __FILE__ in fl_unittest.cpp (the .hpp query path in smart_selector.py depends on this). Making sources relative changes those strings and could silently break .hpp-targeted test selection.

    So the change is plausible and probably correct, but it needs the include flags kept absolute while only the source arguments go relative, plus explicit coverage that FL_TEST_FILE_FILTER still resolves. Filing this analysis rather than a rushed patch, since both prior failures in this area were of the silent-and-confusing variety.

    Cheap interim workaround: use a short worktree branch name (≤ ~5 chars) — at 2 chars nothing crosses the limit. Enabling Windows long-path support (LongPathsEnabled) is the other environment-level escape hatch.

  2. moved this from Triage to Done in FastLED Trackeron Jul 28, 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