Skip to content

feat(config): make baseline the default path.mode - #738

Open
linghengqian wants to merge 2 commits into
version-fox:mainfrom
linghengqian:feat/path-mode-baseline-default
Open

linghengqian wants to merge 2 commits into
version-fox:mainfrom
linghengqian:feat/path-mode-baseline-default

Conversation

@linghengqian

Copy link
Copy Markdown
Member

Part of #737 (item 3, "Change the default of path.mode to baseline").

What changes

path.mode defaults to baseline. The default was legacy, which keeps every PATH entry in front of vfox's first directory in front of it, so a system directory that macOS path_helper or the Windows machine PATH put there kept winning over the version vfox use selected (#337, #732). baseline moves what was already in PATH when vfox activate ran behind vfox's directories, and keeps what is added afterwards (a virtualenv, the $PNPM_HOME of pnpm setup) in front. The way back is one line: vfox config path.mode legacy.

Checked with real binaries, built from main and from this branch. The shell's PATH is <system dir with alphatool>:<vfox sdks dir>:/usr/bin:/bin when vfox activate bash runs, which is the shape behind #337 and #732:

alphatool runs PATH starts with
main (default legacy) the system's system dir, vfox dir
this branch, nothing configured vfox's vfox dir, system dir
this branch + vfox config path.mode legacy the system's system dir, vfox dir
this branch + path.preserve listing the system dir the system's system dir, vfox dir

Code

  • config.DefaultPathMode names the default in one place. EmptyPath, both fallbacks of Path.EffectiveMode and the starting mode of pathPolicy() use it: the four places listed in Follow-ups of #736: plugin updates, the path.mode default and vfox config #737.
  • The open question in Follow-ups of #736: plugin updates, the path.mode default and vfox config #737, whether a typo should land on the new default: yes. An empty or unknown value is the default, as it was before, so a typo does not fail vfox env, which runs at every prompt.
  • EffectiveMode has to name legacy as a case of its own now. Flipping only the fallbacks would turn mode: legacy into baseline. I removed the case to see: 12 tests in all four packages fail.
  • A shell without a recorded baseline still behaves like legacy in every mode, so upgrading does not reorder the PATH of a shell that is already running. It gets the new default when it is restarted. TestEnvWithoutABaselineBehavesLikeLegacyInEveryMode covers the unconfigured case too.
  • The path.shadowed hint for a directory that was already in PATH at activation said to run vfox config path.mode baseline. That finding can only come up in legacy mode now (baseline moves such a directory behind vfox's, and without a recorded baseline the source is "unknown"), so the hint says that first. The other two hints are still right and unchanged.

Tests

The eleven tests that the flip breaks, as counted in #737, are updated: 4 in cmd/commands, 4 in internal/config, 2 in internal/env, 1 in internal/sdk.

Five more kept passing for the wrong reason. They used baseline as the value that has to survive a merge, a save, the first run with a shared VFOX_HOME or an alias change; once it is the default, losing it would not show. They use legacy now: TestMergePath, TestPathRoundTripThroughYAML, TestSharedSettingsApplyOverANewUserConfigFile, TestAFreshUserFollowsTheSharedConfig, TestAliasChangesLeaveTheRestOfTheUserConfigAlone.

New: TestDefaultPathModeIsBaseline, and the unconfigured and legacy cases in the activate, env and use tests. Breaking the implementation four ways (no legacy case, pathPolicy() starting from legacy, unknown values falling back to legacy, EmptyPath staying legacy) fails tests each time.

Docs

English and zh-hans. Quick Start and both READMEs lose the "set baseline" step and the announcement; they are identical to v1.0.13 again. The configuration guide described what legacy does as the general behavior; it now describes the default, and says how to keep the 1.0.x behavior (vfox config path.mode legacy, or path.preserve when a few directories have to stay in front). The FAQ says what can still win (pnpm, anything added after vfox activate) and what to check when vfox doctor still names a system directory (a shell started before the upgrade, legacy, path.preserve). AGENTS.md says where the default lives.

Not in this PR

Draft for the release notes

Changed default: path.mode is baseline. vfox now puts its directories in front of whatever was in PATH when vfox activate ran, so the system's node or java (macOS path_helper, the Windows machine PATH) no longer hides the version you selected. What is added to PATH after activation, such as a virtualenv, still stays in front. To get the behavior of 1.0.x back, run vfox config path.mode legacy; to keep a few directories in front, list them in path.preserve. A shell that was started before the upgrade keeps the old order until you open a new terminal.

Verification

go test on all packages except internal/shared/printer (it needs a TTY), run on the exported tree of HEAD: pass. go vet on Linux, GOOS=windows and GOOS=darwin: clean. The docs site builds (VitePress, no dead links; the new callouts render in both languages).

On Windows most tests that exercise the PATH order skip, as before (they use POSIX paths, and the CLI fixture skips there, #737 item 5). The internal/config tests, which pin the default and its fallbacks, run there.

CI on my fork for the head commit (3703b90) is green: VersionFox CI (ubuntu, macOS, Windows, the Windows regressions, Fish) and vfox E2E Test (Unix, macOS, Windows, MSIX packaging): CI, E2E.

`legacy` keeps every PATH entry in front of vfox's first directory in
front of it, so a system directory that macOS path_helper or the Windows
machine PATH put there keeps winning over the version `vfox use`
selected (version-fox#337, version-fox#732). `baseline` fixes that by moving what was already
in PATH when `vfox activate` ran behind vfox's directories, but everyone
had to opt in with `vfox config path.mode baseline`. It is the default
now; `vfox config path.mode legacy` brings back the behavior of 1.0.x.

- config.DefaultPathMode names the default in one place. EmptyPath, both
  fallbacks of Path.EffectiveMode and the starting mode of pathPolicy()
  use it.
- An empty or unknown mode is the default, as before, so a typo lands on
  baseline instead of failing `vfox env`, which runs at every prompt.
  EffectiveMode names `legacy` as a case of its own now, because it is
  no longer what the fallback returns.
- A shell without a recorded baseline still behaves like legacy in every
  mode, so upgrading does not reorder the PATH of a running shell.
- The path.shadowed hint for a directory that was already in PATH at
  activation can only come up in legacy mode now. It says so before it
  suggests `vfox config path.mode baseline`.

Tests: the eleven that asserted the old default are updated. Tests that
used `baseline` as the value that has to survive a merge, a save or a
shared config would have passed for the wrong reason once it became the
default, so they use `legacy`. New checks pin the default and its
fallbacks, and that an unconfigured vfox leaves the PATH of a shell
without a baseline alone.

Part of version-fox#737
Quick Start and both READMEs no longer ask new installations to run
`vfox config path.mode baseline`, and the configuration guide, the FAQ
and AGENTS.md stop announcing that the default will change. Quick Start
and the READMEs read as they did before version-fox#736 added that step.

- Configuration guide (en, zh-hans): the section described what `legacy`
  does as the general behavior. It now says that `baseline` is the
  default, what `legacy` is, and how to keep the behavior of vfox 1.0.x:
  `vfox config path.mode legacy`, or `path.preserve` when only a few
  directories have to stay in front.
- FAQ (en, zh-hans): a system JDK or a Homebrew node in front of vfox's
  directories no longer wins by default. It lists what still can (pnpm
  and anything added after `vfox activate`) and what to check when
  `vfox doctor` still names a system directory: a shell that was started
  before the upgrade, `legacy`, or `path.preserve`.
- AGENTS.md: where the default is defined and what has to stay in step.

Part of version-fox#737
@linghengqian linghengqian added the enhancement New feature or request label Oct 23, 2026
@codecov

codecov Bot commented Oct 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 51.39%. Comparing base (10c9f96) to head (3703b90).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #738   +/-   ##
=======================================
  Coverage   51.39%   51.39%           
=======================================
  Files         111      111           
  Lines        8240     8240           
=======================================
  Hits         4235     4235           
  Misses       3583     3583           
  Partials      422      422           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@linghengqian linghengqian left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CC @aooohan . Could you please take a look and review this?

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant