Skip to content

fix(embedded): Windows protoc fails with extended-length path from canonicalize() #39

@polaz

Description

@polaz

Problem

Building `coordinode-embedded` on Windows fails because `canonicalize()` in `coordinode-raft/build.rs` returns a Windows extended-length path (UNC prefix `\\?\`) that protoc does not support:

```
Error: protoc failed: Invalid file name pattern or missing input file
"\\?\D:\a\...\proto/coordinode/v1/replication/raft.proto"
```

`std::path::Path::canonicalize()` on Windows produces `\\?\D:\...\path` which is a verbatim UNC prefix. protoc does not handle this prefix and rejects the path.

Suggested fix

In `coordinode-rs/crates/coordinode-raft/build.rs`, strip the `\\?\` prefix on Windows before passing the path to protoc:

```rust
#[cfg(target_os = "windows")]
fn strip_unc_prefix(p: std::path::PathBuf) -> std::path::PathBuf {
let s = p.to_string_lossy();
if let Some(stripped) = s.strip_prefix(r"\\?\") {
std::path::PathBuf::from(stripped)
} else {
p
}
}
```

Or use the `dunce` crate (already common in Rust build scripts) which simplifies `\\?\` paths portably.

Files involved

  • `coordinode-rs/crates/coordinode-raft/build.rs`

Context

Observed in CI: build job `build-embedded / windows-latest` after merging PR #37.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions