Skip to content

fix(cli): match any env sourcing spelling and skip comments in profile detection - #3660

Merged
fengmk2 merged 7 commits into
mainfrom
triagebot/fix-3659
Dec 5, 2026
Merged

fengmk2 merged 7 commits into
mainfrom
triagebot/fix-3659

Conversation

@voidzero-bot

@voidzero-bot voidzero-bot Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

vp checked whether a shell profile sources its env file with substring checks. vp env doctor reported working lines such as . "$HOME"/.config/vite-plus/env and . ${HOME}/.config/vite-plus/env as missing, and first-use setup appended a second sourcing block. A commented-out line counted as configured.

profile_sources_env in commands/shell.rs now splits the profile into shell commands with the rules of the profile's shell. A backslash before a newline, or a trailing &&, || or |, continues a command on the next line. The check removes quotes, resolves backslash escapes, expands $HOME, ${HOME} and a leading ~, skips one --, and compares the argument of a . or source command with the absolute env file path. vp env doctor, first-use setup and the vp env setup guidance check use it. install-legacy.sh stays unchanged: it runs only for old binaries without self-setup support.

A variable expands to every value that it can hold. POSIX NAME=value and export NAME=value set it, an assignment after && or || or inside an if block adds a value, and for NAME in ... gives each listed value. The command counts when any value matches. Nushell profiles also accept backtick quotes, expand a quoted ~, and keep $ literal.

Closes #3659

Automated triage bot fix (AI-assisted).

@github-actions

github-actions Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

✅ Staging deployment successful!

Preview: https://viteplus-staging.void.app/
Commit: d601b6f

@github-actions

github-actions Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

CLI artifact sizes (c1fad39)

Final release artifacts built by the canonical build-upstream and build-windows-cli actions.
The dist rows use the Linux build. The core total excludes .node files to match the release artifact.

Artifact Format Base PR Change
packages/cli/dist Directory total 2.52 MiB 2.52 MiB 0 B (0.00%)
packages/core/dist Directory total 4.29 MiB 4.29 MiB 0 B (0.00%)
Combined package dist Directory total 6.81 MiB 6.81 MiB 0 B (0.00%)
vp (Linux x64) Binary 9.30 MiB 9.31 MiB +8.00 KiB (+0.08%)
vp (Linux x64) gzip -9 4.25 MiB 4.26 MiB +4.62 KiB (+0.11%)
NAPI (Linux x64) Binary 37.99 MiB 37.99 MiB 0 B (0.00%)
NAPI (Linux x64) gzip -9 15.33 MiB 15.33 MiB 0 B (0.00%)
vp (macOS ARM64) Binary 6.11 MiB 6.12 MiB +16.19 KiB (+0.26%)
vp (macOS ARM64) gzip -9 3.64 MiB 3.65 MiB +3.62 KiB (+0.10%)
NAPI (macOS ARM64) Binary 44.39 MiB 44.39 MiB 0 B (0.00%)
NAPI (macOS ARM64) gzip -9 19.42 MiB 19.42 MiB 0 B (0.00%)
vp (Windows x64) Binary 7.26 MiB 7.27 MiB +8.50 KiB (+0.11%)
vp (Windows x64) gzip -9 3.33 MiB 3.33 MiB +6.15 KiB (+0.18%)
NAPI (Windows x64) Binary 33.88 MiB 33.88 MiB 0 B (0.00%)
NAPI (Windows x64) gzip -9 14.04 MiB 14.04 MiB -1 B (-0.00%)
Trampoline (Windows x64) Binary 13.50 KiB 13.50 KiB 0 B (0.00%)
Trampoline (Windows x64) gzip -9 7.09 KiB 7.09 KiB 0 B (0.00%)
Installer (Windows x64) Binary 4.70 MiB 4.70 MiB 0 B (0.00%)
Installer (Windows x64) gzip -9 2.25 MiB 2.25 MiB +1 B (+0.00%)

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

Cloudflare builds and deploys previews for this pull request. Learn more about Cloudflare previews.

Worker Status Deployment Commit
viteplus-dev Deployed Preview c1fad39

Updated: Dec 5, 2026, 17:05 UTC | Dashboard

@fengmk2
fengmk2 force-pushed the triagebot/fix-3659 branch from c427ffa to ae66f88 Compare December 5, 2026 13:45
@fengmk2 fengmk2 self-assigned this Dec 5, 2026
voidzero-bot Bot and others added 5 commits December 6, 2026 00:36
Replace the substring matcher and per-caller spelling lists with one
`profile_sources_env` helper in `commands/shell.rs`. It splits each
profile line into shell words, removes quotes, resolves backslash
escapes, expands `$HOME`, `${HOME}` and a leading `~`, and compares the
argument of a `.` or `source` command with the absolute env file path.
`vp env doctor`, first-use setup and the `vp env setup` guidance check
all use it.

The matcher now also accepts `then . ...`, Fish `; and source ...`, a
tab after `.`, and redirects after the path. It rejects lines that only
print the path, such as `echo "hint; . $HOME/..."`. Doctor also finds
the escaped line that vp writes for a home path with `$` or a backtick.

Revert the `install-legacy.sh` change: that script runs only for old
binaries without self-setup support.

Closes #3659
Pass the profile's shell to `profile_sources_env` through a new
`ShellProfile::shell()`:

- Only Nushell expands a quoted leading `~`. Bash, Zsh and Fish keep
  `source "~/..."` literal, so the line no longer counts as configured.
- Nushell keeps `$` literal in strings and paths.
- POSIX and Fish profiles may put `--` between `.` or `source` and the
  file name.
- POSIX profiles may name the env file through a variable from an
  earlier `NAME=value` or `export NAME=value` line. A later assignment
  replaces the value, and an assignment that the check cannot resolve,
  such as `$(...)`, clears it.
A variable now holds every value that it can have at a line:

- An assignment after `&&`, `||`, `|` or `&`, or in an `if`, `case`,
  `for`, `select`, `while` or `until` block, adds its value. An
  unconditional assignment replaces the earlier values. This keeps
  `vp_env=...; [ -f "$vp_env" ] || vp_env=...` configured.
- In POSIX and Fish profiles, `for NAME in WORD...` gives `NAME` each
  listed value, so a loop that sources `"$f"` counts.

A `.` or `source` command counts when any value of its argument is the
env file. One word or variable keeps at most 64 values.

Nushell profiles also accept backtick quotes, as in
`source `~/My Tools/vite-plus/env.nu``.
Split the whole profile at once and treat a newline as a command
separator. A backslash before a newline joins the lines, outside quotes
and in double quotes, so a `for f in \` list keeps all its values. A
newline after `&&`, `||` or `|` does not end the command, so a fallback
assignment on the next line stays conditional.

A comment still ends at its newline, and a backslash in single quotes
stays in the word. A quote ends at the end of its line, so that an
apostrophe in a heredoc cannot hide the rest of the profile. Nushell
keeps `\` literal.
@fengmk2
fengmk2 force-pushed the triagebot/fix-3659 branch from 86afe4a to fa66046 Compare December 5, 2026 16:37
Add `ShellProfile::sources_env` so doctor, setup and first-use setup no
longer build the env file path and home string themselves, and make
`profile_sources_env` private.

In the scanner, skip words that do not start a command before expanding
them, expand the `.`/`source` argument once, and keep the command prefix
words in one constant. Derive the word state in the splitter from the
word itself instead of a separate flag, use `std::path::is_separator`,
and stop collecting `for` values past the value limit.

Trim caller tests that repeat the matcher tests.
@fengmk2
fengmk2 added this pull request to stack #3709 December 5, 2026 17:15
@fengmk2
fengmk2 merged commit 92c2661 into main Dec 5, 2026
85 checks passed
@fengmk2
fengmk2 deleted the triagebot/fix-3659 branch December 5, 2026 17:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Profile detection misses "$HOME"/... lines and accepts commented ones

1 participant