Skip to content

Commit 611729c

Browse files
authored
fix(cli): show binary location when shell config is not writable (#1060)
When shell config files are read-only (e.g., managed by Nix), the installer now shows where vp was installed and how to run it directly, instead of a confusing permission error. On Windows, PATH failure is no longer fatal — the installer completes and shows manual instructions. Adds CI test for readonly shell config scenario on Linux.
1 parent 644c3b9 commit 611729c

3 files changed

Lines changed: 60 additions & 1 deletion

File tree

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

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,41 @@ jobs:
114114
vp upgrade --rollback
115115
vp --version
116116
117+
test-install-sh-readonly-config:
118+
name: Test install.sh (readonly shell config)
119+
runs-on: ubuntu-latest
120+
permissions:
121+
contents: read
122+
steps:
123+
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
124+
125+
- name: Make shell config files read-only
126+
run: |
127+
# Simulate Nix-managed or read-only shell configs
128+
touch ~/.bashrc ~/.bash_profile ~/.profile
129+
chmod 444 ~/.bashrc ~/.bash_profile ~/.profile
130+
131+
- name: Run install.sh
132+
run: |
133+
output=$(cat packages/cli/install.sh | bash 2>&1) || {
134+
echo "$output"
135+
echo "Install script exited with non-zero status"
136+
exit 1
137+
}
138+
echo "$output"
139+
# Verify installation succeeds (not a fatal error)
140+
echo "$output" | grep -q "successfully installed"
141+
# Verify fallback message shows binary location
142+
echo "$output" | grep -q "vp was installed to:"
143+
# Verify fallback message shows manual instructions
144+
echo "$output" | grep -q "Or run vp directly:"
145+
# Verify the permission warning was shown
146+
echo "$output" | grep -qi "permission denied"
147+
148+
- name: Verify vp works via direct path
149+
run: |
150+
~/.vite-plus/bin/vp --version
151+
117152
test-install-sh-arm64:
118153
name: Test install.sh (Linux ARM64 glibc via QEMU)
119154
runs-on: ubuntu-latest

packages/cli/install.ps1

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,8 @@ function Configure-UserPath {
183183
$env:Path = "$binPath;$env:Path"
184184
return "true"
185185
} catch {
186-
Write-Error-Exit "Cannot update user PATH. Please check your system permissions and re-run the installer."
186+
Write-Warn "Could not update user PATH automatically."
187+
return "failed"
187188
}
188189
}
189190

@@ -428,6 +429,7 @@ exec "`$VITE_PLUS_HOME/current/bin/vp.exe" "`$@"
428429
# ANSI color codes for consistent output
429430
$e = [char]27
430431
$GREEN = "$e[32m"
432+
$YELLOW = "$e[33m"
431433
$BRIGHT_BLUE = "$e[94m"
432434
$BOLD = "$e[1m"
433435
$DIM = "$e[2m"
@@ -463,6 +465,22 @@ exec "`$VITE_PLUS_HOME/current/bin/vp.exe" "`$@"
463465
Write-Host " Note: Restart your terminal and IDE for changes to take effect."
464466
}
465467

468+
# Show manual PATH instructions if PATH could not be configured
469+
if ($pathResult -eq "failed") {
470+
Write-Host ""
471+
Write-Host " ${YELLOW}note${NC}: Could not automatically add vp to your PATH."
472+
Write-Host ""
473+
Write-Host " vp was installed to: ${BOLD}${displayDir}\bin${NC}"
474+
Write-Host ""
475+
Write-Host " To use vp, manually add it to your PATH:"
476+
Write-Host ""
477+
Write-Host " [Environment]::SetEnvironmentVariable('Path', '$InstallDir\bin;' + [Environment]::GetEnvironmentVariable('Path', 'User'), 'User')"
478+
Write-Host ""
479+
Write-Host " Or run vp directly:"
480+
Write-Host ""
481+
Write-Host " & `"$InstallDir\bin\vp.exe`""
482+
}
483+
466484
Write-Host ""
467485
}
468486

packages/cli/install.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -721,6 +721,8 @@ NPMRC_EOF
721721
echo ""
722722
echo -e " ${YELLOW}note${NC}: Could not automatically add vp to your PATH."
723723
echo ""
724+
echo -e " vp was installed to: ${BOLD}${display_location}${NC}"
725+
echo ""
724726
echo " To use vp, add this line to your shell config file:"
725727
echo ""
726728
echo " . \"$INSTALL_DIR_REF/env\""
@@ -729,6 +731,10 @@ NPMRC_EOF
729731
echo " - Bash: ~/.bashrc or ~/.bash_profile"
730732
echo " - Zsh: ~/.zshrc"
731733
echo " - Fish: source \"$INSTALL_DIR_REF/env.fish\" in ~/.config/fish/config.fish"
734+
echo ""
735+
echo " Or run vp directly:"
736+
echo ""
737+
echo -e " ${display_location}/vp"
732738
fi
733739

734740
echo ""

0 commit comments

Comments
 (0)