Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 36 additions & 4 deletions .github/workflows/test-standalone-install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,35 @@ jobs:
- name: Build local vp
run: cargo build --release -p vp_global_cli

- name: CI hides shell file warnings
run: |
set -euo pipefail
eval "$(sed '/^main "[$]@"$/d' packages/cli/install.sh)"

SHELL_CONFIG=$(mktemp)
chmod 444 "$SHELL_CONFIG"

CI=true
RESULT=0
OUTPUT=$(append_source_to_file "$SHELL_CONFIG" '. "$HOME/.vite-plus/env"' 2>&1) || RESULT=$?
test "$RESULT" -eq 3
test -z "$OUTPUT"

VP_LOG=trace
RESULT=0
OUTPUT=$(append_source_to_file "$SHELL_CONFIG" '. "$HOME/.vite-plus/env"' 2>&1) || RESULT=$?
test "$RESULT" -eq 3
echo "$OUTPUT" | grep -F "trace"
echo "$OUTPUT" | grep -F "permission denied"

CI=false
unset VP_LOG
RESULT=0
OUTPUT=$(append_source_to_file "$SHELL_CONFIG" '. "$HOME/.vite-plus/env"' 2>&1) || RESULT=$?
test "$RESULT" -eq 3
echo "$OUTPUT" | grep -F "warn"
echo "$OUTPUT" | grep -F "permission denied"

- name: Incomplete directory overrides are rejected
run: |
set -euo pipefail
Expand Down Expand Up @@ -531,10 +560,13 @@ jobs:
echo "$output" | grep -q "Install locations:"
echo "$output" | grep -q "Data directory: ~/.vite-plus"
echo "$output" | grep -q "Bin directory: ~/.vite-plus/bin"
# Verify fallback message shows manual instructions
echo "$output" | grep -q "Or run vp directly:"
# Verify the permission warning was shown
echo "$output" | grep -qi "permission denied"
# CI gets PATH from the runner environment.
# VP_LOG=trace shows shell file errors.
# Normal output does not show these errors.
if echo "$output" | grep -Eqi "permission denied|Shell configuration:|Some shells still need manual setup"; then
echo "Installer printed shell configuration details in CI"
exit 1
fi

- name: Verify vp works via direct path
run: |
Expand Down
2 changes: 2 additions & 0 deletions docs/guide/installer-env-vars.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,8 @@ Vite+ sets additional `VP_*` variables during shim dispatch and shell integratio
### `VP_LOG`

- **Purpose**: Log filter string for `tracing_subscriber`
- **Installer behavior**: When `CI=true`, `install.sh` hides shell file errors.
Set `VP_LOG=trace` to show these errors.
- **Default**: None
- **Example**:
```bash
Expand Down
33 changes: 27 additions & 6 deletions packages/cli/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,19 @@ warn() {
echo -e "${YELLOW}warn${NC}: $1"
}

trace() {
[ "${VP_LOG:-}" = "trace" ] || return 0
echo -e "${DIM}trace${NC}: $1"
}

report_shell_config_error() {
if [ "${CI:-}" = "true" ]; then
trace "$1"
else
warn "$1"
fi
}

error() {
echo -e "${RED}error${NC}: $1"
exit 1
Expand Down Expand Up @@ -731,7 +744,7 @@ append_source_to_file() {
fi

if [ ! -w "$shell_config" ]; then
warn "Cannot write to $shell_config (permission denied), skipping."
report_shell_config_error "Cannot write to $shell_config (permission denied), skipping."
return 3
fi

Expand All @@ -758,12 +771,12 @@ write_managed_snippet() {

snippet_dir=$(dirname "$snippet_file")
if ! mkdir -p "$snippet_dir" 2>/dev/null; then
warn "Cannot create $snippet_dir, skipping."
report_shell_config_error "Cannot create $snippet_dir, skipping."
return 3
fi

if [ -f "$snippet_file" ] && [ ! -w "$snippet_file" ]; then
warn "Cannot write to $snippet_file (permission denied), skipping."
report_shell_config_error "Cannot write to $snippet_file (permission denied), skipping."
return 3
fi

Expand All @@ -772,7 +785,7 @@ write_managed_snippet() {
fi

if ! printf '%s' "$snippet_content" > "$snippet_file"; then
warn "Cannot write to $snippet_file, skipping."
report_shell_config_error "Cannot write to $snippet_file, skipping."
return 3
fi
return 0
Expand Down Expand Up @@ -807,15 +820,15 @@ configure_zsh_path() {
local result

if ! mkdir -p "$zsh_dir" 2>/dev/null; then
warn "Cannot create $zsh_dir, skipping zsh."
report_shell_config_error "Cannot create $zsh_dir, skipping zsh."
SHELL_CONFIG_HAS_FAILURE="true"
SHELL_CONFIG_FAILED_SHELLS+=("zsh")
record_shell_summary "zsh" "failed (could not create $(abbreviate_path "$zsh_dir"))"
return
fi

if [ ! -f "$zshenv" ] && ! touch "$zshenv" 2>/dev/null; then
warn "Cannot create $zshenv, skipping zsh."
report_shell_config_error "Cannot create $zshenv, skipping zsh."
SHELL_CONFIG_HAS_FAILURE="true"
SHELL_CONFIG_FAILED_SHELLS+=("zsh")
record_shell_summary "zsh" "failed (could not create $(abbreviate_path "$zshenv"))"
Expand Down Expand Up @@ -1442,6 +1455,14 @@ WRAPPER_EOF
echo " Data directory: $display_data_dir"
echo " Bin directory: $display_bin_dir"

# CI jobs configure PATH through the runner.
# Shell files do not change PATH for later steps.
# Do not print shell details in normal CI output.
if [ "${CI:-}" = "true" ]; then
echo ""
return
fi

echo ""
echo " Shell configuration:"
local summary_line
Expand Down
Loading