Skip to content

Commit 6dc2b13

Browse files
committed
fix(installer): 改进 Rust 环境检测失败时的用户提示
当未检测到 Cargo 时,将警告信息从简单的“跳过安装”升级为更友好的提示,包含安装 Rust 的具体建议命令(根据不同平台),以帮助用户后续手动安装相关工具。
1 parent 98c3084 commit 6dc2b13

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

linux/04installApps.ps1

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@ if (Test-EXEProgram -Name 'bun') {
3030
Install-PackageManagerApps -PackageManager 'bun' -ConfigPath $configPath
3131
}
3232

33+
if (Test-EXEProgram -Name 'cargo') {
34+
Install-PackageManagerApps -PackageManager 'cargo' -ConfigPath $configPath
35+
} else {
36+
Write-Warning "未检测到 Rust 环境 (Cargo),跳过 Rust 工具安装"
37+
Write-Host "建议安装 Rust 以支持相关工具 (如 pwshfmt-rs):" -ForegroundColor Cyan
38+
Write-Host " curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh" -ForegroundColor Cyan
39+
}
40+
3341
if ( -not (Test-EXEProgram -Name 'docker')) {
3442
# bash ./ubuntu/installer/install_docker.sh
3543
bash ./ubuntu/installer/installDocker.sh

profile/installer/installApp.ps1

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,10 @@ function Install-DevelopmentTools() {
9898
Install-PackageManagerApps -PackageManager "cargo" -ConfigPath $ConfigPath
9999
}
100100
else {
101-
Write-Host "Cargo 未安装,跳过 Rust 工具安装" -ForegroundColor Yellow
101+
Write-Warning "未检测到 Rust 环境 (Cargo),跳过 Rust 工具安装"
102+
Write-Host "建议安装 Rust 以支持相关工具 (如 pwshfmt-rs):" -ForegroundColor Cyan
103+
Write-Host " 方式 1: 访问 https://rustup.rs/ 下载安装程序" -ForegroundColor Cyan
104+
Write-Host " 方式 2: winget install Rustlang.Rustup" -ForegroundColor Cyan
102105
}
103106

104107
Write-Host "所有工具安装完成!" -ForegroundColor Green

0 commit comments

Comments
 (0)