Skip to content

Commit 76dbde2

Browse files
aooohanclaude
andcommitted
fix: preserve system PATH in activate command
activate.go was using CleanSystemPaths() which only returns paths after the first vfox path, discarding prefixPaths (paths before vfox). This caused system paths like /usr/local/bin, /usr/bin, /bin to be lost when they appeared before vfox paths in PATH. Now uses SplitSystemPaths() like env.go to properly preserve all system paths in the correct priority order. Fixes #626 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 7114a9c commit 76dbde2

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

cmd/commands/activate.go

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -148,12 +148,21 @@ func activateCmd(ctx context.Context, cmd *cli.Command) error {
148148
scopePriority := []env.UseScope{env.Project, env.Session, env.Global}
149149
finalEnvs.MergeByScopePriority(envsByScope, scopePriority)
150150

151-
// 3. Build final PATH with proper priority: Project > Session > Global > Cleaned System PATH
152-
// Get clean system PATH (removes all vfox-managed paths)
153-
cleanSystemPaths := runtimeEnvContext.CleanSystemPaths()
154-
155-
// Merge in priority order: vfox paths (already sorted by scope) > clean system paths
156-
finalEnvs.Paths.Merge(cleanSystemPaths)
151+
// 3. Build final PATH with proper priority:
152+
// User-injected paths (e.g., virtualenv) > Project > Session > Global > Cleaned System PATH
153+
//
154+
// SplitSystemPaths separates:
155+
// - prefixPaths: paths appearing BEFORE first vfox path (user-injected, highest priority)
156+
// - cleanSystemPaths: remaining non-vfox paths (lowest priority)
157+
prefixPaths, cleanSystemPaths := runtimeEnvContext.SplitSystemPaths()
158+
159+
// Build final path order: prefix > vfox > clean system
160+
// We need to prepend prefixPaths to maintain their highest priority
161+
newPaths := env.NewPaths(env.EmptyPaths)
162+
newPaths.Merge(prefixPaths)
163+
newPaths.Merge(finalEnvs.Paths)
164+
newPaths.Merge(cleanSystemPaths)
165+
finalEnvs.Paths = newPaths
157166

158167
// 4. Export environment variables
159168
// Note: This step must be the first.

0 commit comments

Comments
 (0)