Skip to content

Commit 42de16f

Browse files
committed
fix(installer): document directory behavior and fix CI
1 parent e132fc4 commit 42de16f

3 files changed

Lines changed: 56 additions & 15 deletions

File tree

‎.github/workflows/test-standalone-install.yml‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1253,6 +1253,10 @@ jobs:
12531253
}
12541254
}
12551255
1256+
# Each installer process must fail in this test. Reset the native
1257+
# exit code after the assertions so the PowerShell step succeeds.
1258+
$global:LASTEXITCODE = 0
1259+
12561260
- name: vp-setup.exe pre-split fallback leaves no split roots
12571261
shell: pwsh
12581262
run: |

‎rfcs/directory-layout.md‎

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,13 @@ Thus, `user_home` and `dirs` cannot use different home directories. Directory
146146
resolution reads only `VP_HOME`, `VP_*_DIR`, and `XDG_*`. It does not read
147147
`HOME` or `USERPROFILE`.
148148

149+
`crates/vp_shared/src/dirs/env_overrides.rs` classifies `VP_HOME`,
150+
`VP_BIN_DIR`, `VP_DATA_DIR`, and `VP_CACHE_DIR` as unset, absolute, or
151+
relative. Runtime resolution accepts absolute candidates and skips invalid
152+
candidates. `validate_vp_dir_env` applies the installer policy to the same
153+
classification. The function returns an error for a relative `VP_HOME`, an
154+
incomplete split group, or a relative path in a complete split group.
155+
149156
Directory resolution has no test-only branches. Tests use the process
150157
environment to run the production resolution chain. See
151158
[Test configuration](#test-configuration).
@@ -242,16 +249,17 @@ A restricted service or CI environment can prevent the known-folder query.
242249
When this occurs, Vite+ uses `AppData\Local` and `AppData\Roaming` under the
243250
resolved user home. Thus, a known home always produces a complete layout.
244251

245-
| Source | Behavior |
252+
| Source | Runtime behavior |
246253
| ------------------------------------------------- | --------------------------------------------------------------------------------------------------- |
247254
| **`VP_HOME`** | Vite+ puts the **monolithic mapping** for all categories under this root. |
248255
| **`~/.vite-plus`** | Vite+ uses the monolithic mapping when this directory contains a `current` link. |
249256
| **`VP_BIN_DIR` / `VP_DATA_DIR` / `VP_CACHE_DIR`** | All three values must be set to absolute paths. An incomplete or invalid group has no effect. |
250257
| **`XDG_*`** (Unix) | Vite+ uses absolute XDG category roots with the app name `vite-plus`. Bin resolves to `<DATA>/bin`. |
251258
| **Platform defaults** | [Category mapping](#category-mapping) defines the Unix and Windows defaults. |
252259

253-
Vite+ ignores relative `VP_*` and `XDG_*` values. This behavior follows the XDG
254-
Base Directory Specification.
260+
Runtime resolution ignores relative `VP_*` and `XDG_*` values. This behavior
261+
follows the XDG Base Directory Specification. Installers apply stricter rules
262+
before they create installation roots.
255263

256264
### Category mapping
257265

@@ -314,12 +322,19 @@ root. Features must not store machine identity or durable state in these files.
314322
`install.sh`, `install.ps1`, and the local `install-global-cli` use the CLI
315323
resolution chain:
316324

317-
1. If `VP_HOME` is set, use that root for the **monolithic** layout.
325+
1. If `VP_HOME` contains an absolute path, use that root for the
326+
**monolithic** layout.
318327
2. Otherwise, check the default `~/.vite-plus` directory or its Windows
319328
equivalent. If it contains a `current` link, keep the monolithic root.
320329
3. Otherwise, use a complete `VP_*_DIR` group, `XDG_*`, or platform defaults
321330
for the **split** layout.
322331

332+
The script installers reject an incomplete or relative `VP_*_DIR` group.
333+
`vp-setup` rejects those groups and a relative `VP_HOME`. It calls
334+
`vp_shared::validate_vp_dir_env` before `EnvConfig` resolves paths. A validation
335+
error makes `vp-setup` exit with status 1 before it creates a requested or
336+
default installation root.
337+
323338
Each platform has one install script. There is no separate script for each
324339
layout. Local bootstrap does not set `VP_HOME`. It resolves the install data
325340
directory through the same chain.
@@ -387,8 +402,8 @@ However, the installer still exits with status 0:
387402
**Detection.** Each installer downloads the platform payload before it selects
388403
the final layout. This includes `install.sh`, `install.ps1`, and `vp-setup`. The
389404
installer then runs the payload binary once with `VP_DUMP_DIRS=1`. The shell and
390-
PowerShell installers do not resolve `VP_*_DIR`, XDG variables, platform
391-
defaults, or legacy installs themselves:
405+
PowerShell installers validate the split override group, but they do not
406+
resolve `VP_*_DIR`, XDG variables, platform defaults, or legacy installs:
392407

393408
- A current split-aware binary prints the layout mode and one tab-separated line
394409
for each category root. The categories are `bin`, `data`, `cache`, `config`,
@@ -431,7 +446,10 @@ directories for the success summary.
431446
The wrapper install uses managed Node.js and pnpm. These tools get their paths
432447
from the process-wide `EnvConfig`, which resolves before the fallback. Therefore,
433448
the tools first go into the unused split data root. `do_install` removes this
434-
root if the current run created it.
449+
root if the current run created it. Before the probe, `vp-setup` records
450+
whether the split data parent exists. After a legacy fallback, it removes that
451+
parent with a non-recursive operation if the current run created it and left it
452+
empty. Existing parents and parents with new contents remain in place.
435453

436454
The interactive menu has one known limit. It shows the split directories before
437455
the download. For a pinned pre-split version, the user confirms those
@@ -452,6 +470,11 @@ define the boundary.
452470
pre-split release without `VP_HOME`. They check the monolithic layout, the
453471
absence of split roots, and commands that run through `PATH`.
454472

473+
The `test-vp-setup-exe` job rejects each incomplete split-variable combination,
474+
a relative `VP_HOME`, and a relative complete split group. It checks that
475+
validation creates no requested or default roots. The pinned `0.2.9` case
476+
checks that the legacy install works and that no empty split root remains.
477+
455478
This mechanism also keeps fresh default installs of `latest` functional before
456479
the 0.3.0 release becomes available.
457480

‎rfcs/windows-installer.md‎

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ vp-setup.exe --version 0.3.0 --no-node-manager --registry https://registry.npmmi
188188
| `-q` / `--quiet` | Suppress output except errors | false |
189189
| `--version <VER>` | Install specific version | latest |
190190
| `--tag <TAG>` | npm dist-tag | latest |
191-
| `--install-dir <PATH>` | Installation directory | `%USERPROFILE%\.vite-plus` |
191+
| `--install-dir <PATH>` | Installation directory | resolved Vite+ layout |
192192
| `--registry <URL>` | npm registry URL | `https://registry.npmjs.org` |
193193
| `--no-node-manager` | Skip Node.js manager setup | auto-detect |
194194
| `--no-modify-path` | Don't modify User PATH | modify |
@@ -198,12 +198,20 @@ vp-setup.exe --version 0.3.0 --no-node-manager --registry https://registry.npmmi
198198
| Variable | Maps to |
199199
| ------------------------- | ------------------- |
200200
| `VP_VERSION` | `--version` |
201-
| `VP_HOME` | `--install-dir` |
201+
| `VP_HOME` | single-root layout |
202+
| `VP_BIN_DIR` | split bin root |
203+
| `VP_DATA_DIR` | split data root |
204+
| `VP_CACHE_DIR` | split cache root |
202205
| `NPM_CONFIG_REGISTRY` | `--registry` |
203206
| `VP_NODE_MANAGER=yes\|no` | `--no-node-manager` |
204207

205208
CLI flags take precedence over environment variables.
206209

210+
`vp-setup.exe` requires an absolute `VP_HOME`. Callers that set a split root
211+
must set all three `VP_*_DIR` variables to absolute paths. The installer calls
212+
the shared `vp_shared::validate_vp_dir_env` check before it resolves or creates
213+
installation roots. The installer returns exit code 1 for invalid configuration.
214+
207215
## Installation Flow
208216

209217
The installer replicates the same result as `install.ps1`, implemented in Rust via `vp_setup`.
@@ -215,7 +223,7 @@ The installer replicates the same result as `install.ps1`, implemented in Rust v
215223
│ ┌─ detect platform ──────── win32-x64-msvc │
216224
│ │ win32-arm64-msvc │
217225
│ │ │
218-
│ ├─ check existing ──────── read %VP_HOME%\current │
226+
│ ├─ check existing ──────── read <DATA>\current │
219227
│ │ │
220228
│ └─ resolve version ──────── resolve_version_string() │
221229
│ 1 HTTP call: "latest" → "0.3.0" │
@@ -242,7 +250,7 @@ The installer replicates the same result as `install.ps1`, implemented in Rust v
242250
┌─────────────────────────────────────────────────────────────┐
243251
│ INSTALL │
244252
│ │
245-
│ ┌─ extract binary ──────── %VP_HOME%\{version}\bin\ │
253+
│ ┌─ extract binary ──────── <DATA>\{version}\bin\ │
246254
│ │ vp.exe + vp-shim.exe │
247255
│ │ │
248256
│ ├─ generate package.json ─ wrapper with vite-plus dep │
@@ -274,7 +282,7 @@ The installer replicates the same result as `install.ps1`, implemented in Rust v
274282
│ CONFIGURE (best-effort, always runs, │
275283
│ even for same-version repair) │
276284
│ │
277-
│ ┌─ create bin shims ────── copy vp-shim.exe → bin\vp.exe │
285+
│ ┌─ create bin shims ────── copy vp-shim.exe → <BIN>\vp.exe │
278286
│ │ (rename-to-.old if running) │
279287
│ │ │
280288
│ ├─ Node.js manager ────── if enabled (pre-computed): │
@@ -284,7 +292,7 @@ The installer replicates the same result as `install.ps1`, implemented in Rust v
284292
│ │ │
285293
│ └─ modify User PATH ────── if --no-modify-path not set: │
286294
│ HKCU\Environment\Path │
287-
│ prepend %VP_HOME%\bin │
295+
│ prepend <BIN> │
288296
│ broadcast WM_SETTINGCHANGE │
289297
└─────────────────────────────────────────────────────────────┘
290298
│
@@ -464,8 +472,12 @@ test-vp-setup-exe:
464472
# verifies from all three shells after a single install
465473
```
466474

467-
The workflow triggers on changes to `crates/vp_installer/**`, `crates/vp_pm_cli/**`, and
468-
`crates/vp_setup/**`.
475+
The workflow path filter covers the installer, shared directory resolution,
476+
setup helpers, shims, global CLI, install scripts, and the workflow file.
477+
478+
The job checks invalid directory overrides and a pinned `0.2.9` install.
479+
Invalid overrides must leave requested and default roots absent. The old-version
480+
case must produce a working monolithic install and leave no empty split root.
469481

470482
## Code Signing
471483

@@ -572,6 +584,8 @@ Embed the PowerShell script in a self-extracting exe. Fragile, still requires Po
572584
- Fresh install from cmd.exe, PowerShell, Git Bash
573585
- Silent mode (`-y`) installation
574586
- Custom registry, custom install dir
587+
- Invalid `VP_HOME` and `VP_*_DIR` configuration
588+
- Pre-split fallback without an empty split root
575589
- Upgrade over existing installation
576590
- Verify `vp --version` works after install
577591
- Verify PATH is modified correctly

0 commit comments

Comments
 (0)