fix(cli): normalize workspace path to forward slashes for CMake templates - #3040
Conversation
…ates workspace_dir() returned a raw Windows path (backslash-separated), which gets substituted verbatim into __DORA_PATH__ in the generated CMakeLists.txt for --lang c/cxx --internal-create-with-path-dependencies. CMake treats backslash as a string escape character, so cmake -B failed immediately with 'Invalid character escape' before any compiler logic ran. Normalize to forward slashes, which both CMake and Windows accept. Also box the large Cached variant of CachedResult in the coordinator (pre-existing clippy::large_enum_variant failure surfaced while running clippy locally, related to dora-rs#2979).
|
😎 Merged successfully - details. |
|
I reviewed both parts of this diff. The CMake path normalization is correct: replacing Two things worth raising:
🤖 Fully automated review by Claude (Claude Code) — no human has reviewed these findings. Please verify before relying on them. Generated by Claude Code Generated by Claude Code |
… OS-independent test The CachedResult::Cached boxing fix duplicated the already-open PR dora-rs#3001, so it's dropped here to avoid merge conflicts (per 'don't fix unrelated warnings in PRs' convention). The regression test now asserts against a hardcoded Windows-style sample path instead of the live workspace_dir() output, since on Linux/macOS CI the real path never contains a backslash and the old assertion passed trivially without exercising the normalization logic.
|
Thanks for the review. Addressed both points:
Pushed both fixes. Diff is back to just the 3 template files. |
|
🤖 Automated review by Claude — fully automated review, not verified by a human. Reviewed the latest commit ( Generated by Claude Code |
|
@GuTS805 the Trunk merge queue failed for this PR. See the Trunk merge-status comment for details. Posted as a new comment so GitHub sends an email — Trunk's sticky comment is edited in place and won't trigger a notification. |
Problem
workspace_dir()inbinaries/cli/src/template/mod.rsresolved the doraworkspace root from
env!("CARGO_MANIFEST_DIR")and returned it as a raw OSpath. On Windows that's backslash-separated (e.g.
C:\Users\...). Thisstring was substituted verbatim — no escaping — into the
__DORA_PATH__placeholder in the C/C++ CMake templates
(
binaries/cli/src/template/c/mod.rs,binaries/cli/src/template/cxx/mod.rs),producing a generated
CMakeLists.txtline like:CMake treats
\inside a quoted string as an escape character.\U,\D,etc. are not recognized escapes, so
cmake -B buildfailed immediately witha parse error (
Invalid character escape '\U'), before any compiler/generatorlogic ran. This only affects
dora new --lang c/cxx --internal-create-with-path-dependencies(the flag used to build templates against a local checkout) — the default
dora newflow substitutes an empty string and git-clones instead, so itnever hit this.
This is why it was never caught in CI:
.github/workflows/nightly.ymlexercises this exact
dora new --lang c/cxx --internal-create-with-path-dependenciescmake -Bflow, but is gatedif: runner.os == 'Linux', where paths arealready forward-slash.
Fix
workspace_dir()now normalizes\to/before returning, since bothCMake and Windows accept forward slashes. Added a regression test
(
workspace_dir_has_no_backslashes) asserting the returned path nevercontains a backslash.
Verification
doraCLI and randora new test_c_project --lang c --internal-create-with-path-dependencies— the generated
CMakeLists.txtnow containsset(DORA_ROOT_DIR "C:/Users/.../dora" ...)(forward slashes).cmake -B buildon the generated project no longer hits thebackslash-escape parse error (progresses past it to the
project()step;the only remaining error is an unrelated missing MSVC/nmake toolchain on
this machine).
cargo fmt --all -- --check— cleancargo clippy -p dora-cli -- -D warnings— cleancargo test -p dora-cli workspace_dir_has_no_backslashes— passFixes #3038