Repository navigation
fix(env): merge SDK envs in deterministic order to stabilize PATH and env-state cache - #691
Merged
aooohan merged 2 commits intoSep 6, 2026
Conversation
… env-state cache Same-scope PATH entries were ordered by goroutine completion, which is scheduling-dependent. The emitted PATH therefore almost never matched the cached_path recorded in env-state.json once the shell hook eval'd the output, so every 'vfox env' took the slow rebuild path. Collect per-SDK results first and merge them sorted by SDK name after g.Wait(); scope priority is unchanged.
Member
|
Thanks for the contribution. |
xooooooooox
added a commit
to xooooooooox/homebrew-prebuilt
that referenced
this pull request
Sep 7, 2026
Migration target for the retiring patched-tap formula: the PATH-order fix (version-fox/vfox#691) shipped upstream in v1.0.12, and core has no monterey bottle (a source build needs go). Arch-aware urls to the official release tarballs (binary + completions), livecheck github_latest; the bump workflow owns upgrades from here.
xooooooooox
added a commit
to xooooooooox/homebrew-patched
that referenced
this pull request
Sep 7, 2026
Patch (1), deterministic PATH order in vfox env output, merged upstream (version-fox/vfox#691) and shipped in v1.0.12. Patch (2), the shared env cache proposal (#694), was closed unimplemented and is dropped with the formula (~15ms/rebuild trade-off accepted). Mark, don't delete: deprecate!, bottle block removed (releases stay up as history), README row moved to a new Retired table. Replacements: core on current macOS, xooooooooox/prebuilt/vfox on Intel/monterey.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #690
Problem
envFlagmerges each SDK's envs inside its own goroutine, so same-scope PATH entries end up in goroutine completion order — scheduling-dependent and different on every rebuild. Cache validity (internal/env/state.go,HasChanged) compares the current$PATHagainstcached_path, so once the shell hook evals the emitted output,$PATHnever matches again and everyvfox envtakes the slow rebuild path (0.3–3s with a handful of SDKs). With theprecmd/chpwdhook fromvfox activate, that stalls every prompt /cd.Fix
Collect the per-SDK results during the concurrent phase and merge them after
g.Wait()in sorted-by-SDK-name order.user-injected > Project > Session > Global > system,MergeByScopePriority) is untouched — only the ordering of same-scope entries, which was previously random, becomes stable.Verification
go build ./...,go test ./internal/env/... ./internal/sdk/... ./cmd/...pass.eval "$(vfox env -s zsh)"once → the next rebuild records the fixed point → every subsequentvfox envis a cache hit (~10ms,env-state.jsonno longer rewritten). Live zsh with the activate hook:cdcost drops from 0.4–0.5s per directory change to ~20ms.Note: the ordering of
export VAR=...statements still varies between rebuilds (map iteration inShell.Export). That is cosmetic — only PATH participates in cache validity — and is deliberately left out of this PR to keep the diff minimal.