Skip to content

feat: remove VP_HOME and default installers to the split XDG layout - #2349

Closed
forehalo wants to merge 5 commits into
voidzero-dev:mainfrom
forehalo:feat/xdg-installer-cutover
Closed

feat: remove VP_HOME and default installers to the split XDG layout#2349
forehalo wants to merge 5 commits into
voidzero-dev:mainfrom
forehalo:feat/xdg-installer-cutover

Conversation

@forehalo

@forehalo forehalo commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Stacked on #2346 — only the top 4 commits are new. Close #827 on merge of this stack.

Summary

Flips fresh installs to the split XDG layout and removes the VP_HOME variable, completing #827. Existing installs are untouched: a legacy monolithic root is still detected (executable self-location, PATH inference, or an existing ~/.vite-plus) and keeps working byte-for-byte.

Commit 1: remove VP_HOME

The CLI no longer reads VP_HOME. Custom-location installs are located without it via executable self-location (<root>/current/bin/vp, covering IDE and trampoline launches), legacy PATH inference, and the grandfathered ~/.vite-plus check. The Windows trampoline and vp_installer stop setting it.

Commit 2: split-aware detection, env scripts, implode, installer core

  • dirs.rs: detection now distinguishes legacy from split installs via a DetectedLayout enum — a <X>/current/bin/vp shape classifies as legacy when <X>/bin/vp exists, otherwise as a split install whose data dir is X (pinning data to the running binary's payload). PATH inference canonicalizes vp entries through the same shape check.
  • Generated env/env.fish/env.nu/env.ps1 no longer export VP_HOME; they only prepend the resolved bin dir. vp-use.cmd gains the split fallback path.
  • The Windows trampoline locates vp.exe at ../current/bin (legacy) or ../data/current/bin (split).
  • vp implode removes the split layout: data/config/state/cache dirs plus only the vp-owned shim names from the bin dir — a shared ~/.local/bin and foreign files are never touched. Profile stripping catches the env-scripts dir in both layouts.
  • vp_installer resolves an InstallLayout from Dirs, creates the bin wrapper in the resolved bin dir, and prints split-aware guidance. Explicit --install-dir/VP_HOME still selects the legacy layout.

Commit 3: installers default to the split layout

  • install.sh/install.ps1: fresh installs place versions + current under the data dir (~/.local/share/vite-plus, %LOCALAPPDATA%\vite-plus\data), the vp wrapper and shims in the bin dir (~/.local/bin, %LOCALAPPDATA%\vite-plus\bin), and env scripts in the config dir (~/.config/vite-plus, %APPDATA%\vite-plus). Explicit VP_HOME or an existing ~/.vite-plus keeps the legacy layout, so re-running the installer upgrades existing installs in place. Relative XDG values are ignored per spec.
  • Dockerfile drops VP_HOME and uses the split layout.
  • Docs describe the split layout as the fresh-install default and VP_HOME as an installer-only override.

Commit 4: snapshot fixtures

  • The runner provisions the complete legacy shape (bin/vp alongside current/bin/vp) so detection classifies case homes as legacy installs.
  • Two fixtures that pointed at isolated installs via per-step VP_HOME now model the same isolation with real on-disk layouts driven through their own binaries (self-location).
  • The git-hooks migration snapshot picks up PR feat: XDG directory layout via VpDirs #2346's new hook-script PATH fallback chain.

Migration impact

  • Existing ~/.vite-plus installs: zero impact (grandfathered; detection is byte-identical in behavior).
  • Custom VP_HOME installs: keep working — the running binary self-locates from its own path. The variable itself is ignored by the CLI and no longer exported by generated env scripts.
  • Fresh installs: land in the split layout; ~/.local/bin is the only PATH entry needed.

Validation

  • cargo check/clippy --workspace --all-targets: zero warnings; cargo fmt clean
  • cargo test on all touched crates: green
  • PTY snapshot suite: 622/622 cases pass locally (including two rewritten fixtures and the browser-mode case)

Add vp_shared::Dirs as the single owner of on-disk placement decisions.
An internal DirsInner enum selects the layout once per resolution (first
match wins):

- Home (legacy monolithic root): VP_HOME is set, the vp binary
  self-locates at <root>/current/bin/vp, a legacy layout is found on
  PATH, or ~/.vite-plus exists on disk. Existing installs keep working
  untouched, byte-identical paths.
- Custom (split XDG layout, fresh installs): each category resolves
  through its own VP_*_DIR override -> XDG_* -> platform-default chain
  (bin: VP_BIN_DIR -> XDG_BIN_HOME -> XDG_DATA_HOME/../bin -> ~/.local/bin,
  mirroring uv). Only VP_BIN_DIR/VP_DATA_DIR/VP_CACHE_DIR exist as
  dedicated overrides; config and state rely on XDG_CONFIG_HOME /
  XDG_STATE_HOME. Relative values are ignored per the spec.

XDG_* names are defined alongside vp's own variables in env_vars.rs, but
only vp_* path overrides live in EnvConfig; Dirs reads XDG vars itself
behind an injectable, parallel-safe resolution core (no env mutation or
serial_test anywhere in Dirs tests; test helpers live in a #[cfg(test)]
impl block, and cross-crate tests sandbox through
EnvConfig::for_test_with_home).

Migrate every Rust call site to Dirs category accessors and named
helpers, delete get_vp_home() and the home.rs module (folded into
dirs.rs), and drop per-crate wrapper helpers so Dirs is the sole path
source. bins/*.json metadata moves to the data category.

On the TS side, the global CLI injects the resolved VP_BIN_DIR /
VP_DATA_DIR / VP_CACHE_DIR into JS child processes under the split layout
only (never overriding user-set vars); org-tarball.ts prefers
VP_CACHE_DIR; generated git hook scripts fall back through VP_BIN_DIR,
VP_HOME/bin, ~/.vite-plus/bin, ~/.local/bin.

VP_HOME, the installers, and the generated env* shell scripts are
unchanged in behavior: fresh installs still land in ~/.vite-plus, so the
split layout is opt-in via VP_*_DIR/XDG until the follow-up stack removes
the legacy variables and switches installer defaults.

Groundwork for voidzero-dev#827.
The CLI no longer reads VP_HOME. Custom-location installs are located
without it, via (in priority order): executable self-location
(<root>/current/bin/vp, covering IDE and trampoline launches), legacy
PATH inference, and the grandfathered ~/.vite-plus existence check.

The Windows trampoline and vp_installer no longer set VP_HOME for child
processes; the snapshot runner keeps injecting it only for generated env
scripts and fixtures that still reference it (removed with the installer
cutover later in this stack).
Make the split XDG layout fully functional for fresh installs:

- dirs.rs: layout detection now distinguishes legacy from split installs
  via a DetectedLayout enum. Both executable self-location and PATH
  inference canonicalize into the <X>/current/bin/vp shape and classify:
  <X>/bin/vp exists -> legacy root, otherwise X is the split data dir
  (pinning the data category to the running binary's payload).
- env setup scripts no longer export VP_HOME; they prepend the resolved
  bin dir only. vp-use.cmd gains the split-layout fallback path.
- The Windows trampoline locates vp.exe at ../current/bin (legacy) or
  ../data/current/bin (split).
- vp implode removes the split layout: data/config/state/cache dirs plus
  only the vp-owned shim names from the bin dir (a shared ~/.local/bin is
  never removed), and strips profile lines referencing the env-scripts
  dir.
- vp_installer resolves an InstallLayout (install/bin/env-scripts dirs)
  from Dirs, creates the bin wrapper in the resolved bin dir, and prints
  split-aware PATH guidance. Explicit --install-dir/VP_HOME still selects
  the legacy layout for compatibility.
install.sh and install.ps1 now install fresh setups into the split
layout: versions and the current symlink under the data dir
(~/.local/share/vite-plus, %LOCALAPPDATA%\vite-plus\data), the vp
wrapper and shims in the bin dir (~/.local/bin, %LOCALAPPDATA%\vite-plus
\bin), and env scripts in the config dir (~/.config/vite-plus,
%APPDATA%\vite-plus). Explicit VP_HOME/--install-dir or an existing
~/.vite-plus keeps the legacy monolithic layout, so upgrades of existing
installs continue in place. Relative XDG values are ignored per spec.

The Dockerfile drops VP_HOME and uses the split layout. Docs now
describe the split layout as the fresh-install default, VP_HOME as an
installer-only override, and implode as handling both layouts. The
snapshot runner keeps injecting VP_HOME because fixtures expand it in
vpt argv.
The snapshot runner now provisions the complete legacy install shape
(bin/vp alongside current/bin/vp) so layout detection classifies the
case home as a legacy install before vp env setup regenerates shims.

Two fixtures targeted isolated installs through per-step VP_HOME, which
the CLI no longer reads. They now model the same isolation with real
on-disk layouts: the corepack fixture builds an isolated legacy install
at home/.vite-plus and drives it through its own binary, and the
external-vp fixture uses a full second legacy install at external/,
asserting env setup self-locates and links shims into the invoking
install. The git-hooks migration snapshot picks up the new hook-script
PATH fallback chain (VP_BIN_DIR first, ~/.local/bin last).
@netlify

netlify Bot commented Aug 5, 2026

Copy link
Copy Markdown

Deploy Preview for viteplus-preview ready!

Name Link
🔨 Latest commit 35fdfe8
🔍 Latest deploy log https://app.netlify.com/projects/viteplus-preview/deploys/6a736f4da722650008f410cb
😎 Deploy Preview https://deploy-preview-2349--viteplus-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@forehalo

forehalo commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

Consolidated into #2346 — the stack is now a single PR: the Dirs abstraction commit plus the squashed installer-cutover commit (with VP_HOME kept as DEPRECATED_VP_HOME instead of removed outright).

@forehalo forehalo closed this Aug 6, 2026
@forehalo
forehalo deleted the feat/xdg-installer-cutover branch August 6, 2026 06:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

use xdg config

1 participant