Skip to content

Commit 3c85add

Browse files
authored
fix: handle Windows path stripping failures gracefully (#93)
## Summary - Fix Windows path handling that caused "Invalid relative path" errors - On Windows, path stripping may fail due to case sensitivity or path format differences - Instead of failing with an error, treat such paths as outside the workspace (like other unmatched paths) ## Problem When running vite-task on Windows, paths tracked by fspy might have different formats or casing than the workspace root. This caused errors like: ``` Invalid relative path 'D:\a\vite-plus\vite-plus\ecosystem-ci\tanstack-start-helloworld': path is not relative ``` ## Solution Changed the error handling to use `.ok()` instead of `.map_err()` followed by `.transpose()?`, treating conversion failures as paths outside the workspace. ## Test plan - [x] Ran `cargo test -p vite_task` locally - Testing in vite-plus E2E CI 🤖 Generated with [Claude Code](https://claude.com/claude-code)
1 parent 14167c2 commit 3c85add

File tree

1 file changed

+9
-11
lines changed
  • crates/vite_task/src/session/execute

1 file changed

+9
-11
lines changed

crates/vite_task/src/session/execute/spawn.rs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -174,17 +174,15 @@ where
174174
let path_writes = &mut track_result.path_writes;
175175

176176
for access in termination.path_accesses.iter() {
177-
let relative_path = access
178-
.path
179-
.strip_path_prefix(workspace_root, |strip_result| {
180-
let Ok(stripped_path) = strip_result else {
181-
return None;
182-
};
183-
Some(RelativePathBuf::new(stripped_path).map_err(|err| {
184-
anyhow::anyhow!("Invalid relative path '{}': {}", stripped_path.display(), err)
185-
}))
186-
})
187-
.transpose()?;
177+
let relative_path = access.path.strip_path_prefix(workspace_root, |strip_result| {
178+
let Ok(stripped_path) = strip_result else {
179+
return None;
180+
};
181+
// On Windows, paths are possible to be still absolute after stripping the workspace root.
182+
// For example: c:\workspace\subdir\c:\workspace\subdir
183+
// Just ignore those accesses.
184+
RelativePathBuf::new(stripped_path).ok()
185+
});
188186

189187
let Some(relative_path) = relative_path else {
190188
// Ignore accesses outside the workspace

0 commit comments

Comments
 (0)