Skip to content

Commit c98eb4f

Browse files
aooohanclaude
andcommitted
fix: preserve system PATH when no vfox paths exist (#622)
When PATH contains no vfox-managed paths (first activation), all paths should go to cleanPaths, not prefixPaths. Otherwise CleanSystemPaths() returns empty PATH, breaking system commands like mkdir. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent fbc7e73 commit c98eb4f

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

internal/env/context.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,30 @@ func (m *RuntimeEnvContext) SplitSystemPaths() (prefixPaths *Paths, cleanPaths *
127127
prefixPaths = NewPaths(EmptyPaths)
128128
cleanPaths = NewPaths(EmptyPaths)
129129

130+
// First pass: check if there are any vfox paths
131+
hasVfoxPath := false
132+
for _, path := range systemPaths {
133+
if path == "" {
134+
continue
135+
}
136+
if pathmeta.IsVfoxRelatedPath(filepath.Clean(path)) {
137+
hasVfoxPath = true
138+
break
139+
}
140+
}
141+
142+
// If no vfox paths, all paths are clean system paths (no user-injected paths to preserve)
143+
if !hasVfoxPath {
144+
for _, path := range systemPaths {
145+
if path == "" {
146+
continue
147+
}
148+
cleanPaths.Add(path)
149+
}
150+
return prefixPaths, cleanPaths
151+
}
152+
153+
// Second pass: split by first vfox path
130154
foundVfoxPath := false
131155
for _, path := range systemPaths {
132156
if path == "" {

internal/env/context_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ func TestSplitSystemPaths(t *testing.T) {
7878
"/usr/local/bin",
7979
"/usr/bin",
8080
}, ":"),
81-
wantPrefix: []string{"/home/user/venv/bin", "/usr/local/bin", "/usr/bin"},
82-
wantClean: []string{},
81+
wantPrefix: []string{},
82+
wantClean: []string{"/home/user/venv/bin", "/usr/local/bin", "/usr/bin"},
8383
},
8484
{
8585
name: "project vfox path (.vfox directory)",

0 commit comments

Comments
 (0)