Skip to content

Commit 82c9d38

Browse files
committed
fix: handle case-insensitive PATH variable on Windows
- Use strings.EqualFold for case-insensitive PATH detection - Windows environment variables are case-insensitive (PATH vs Path) - Fixes Windows CI test failure in TestRustCompiler_GetRustEnv_WithBothHomes
1 parent 445ae8b commit 82c9d38

File tree

1 file changed

+5
-2
lines changed
  • internal/features/scripting/infrastructure/compilers

1 file changed

+5
-2
lines changed

internal/features/scripting/infrastructure/compilers/rust.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,14 +313,17 @@ func (c *RustCompiler) getRustEnv() []string {
313313

314314
// updatePathInEnv updates the PATH environment variable by prepending newPath
315315
// It removes any existing PATH entry and adds a new one with newPath at the beginning
316+
// Handles both "PATH=" and "Path=" (Windows is case-insensitive)
316317
func updatePathInEnv(env []string, newPath string) []string {
317318
var existingPath string
318319
var result []string
319320

320321
// Find and extract existing PATH, filter it out
322+
// On Windows, PATH can be "Path=" or "PATH=" (case-insensitive)
321323
for _, e := range env {
322-
if strings.HasPrefix(e, "PATH=") {
323-
existingPath = strings.TrimPrefix(e, "PATH=")
324+
// Check for PATH= with case-insensitive comparison
325+
if len(e) >= 5 && strings.EqualFold(e[:5], "PATH=") {
326+
existingPath = e[5:]
324327
} else {
325328
result = append(result, e)
326329
}

0 commit comments

Comments
 (0)