fix(installer): dependency installation for Windows (#4486)

* Add info for bad make path on windows during installation

* wip

* Update install.ps1

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip!

* fix typos

* add back exit 1
This commit is contained in:
Jan Bronicki 2024-02-05 10:25:45 -08:00 committed by GitHub
parent e85637c240
commit 4ffa7c455b
WARNING! Although there is a key with this ID in the database it does not verify this commit! This commit is SUSPICIOUS.
GPG key ID: B5690EEEBB952194

View file

@ -85,18 +85,25 @@ function print_missing_dep_msg($dep) {
Write-Output "Please install it first and re-run the installer." Write-Output "Please install it first and re-run the installer."
} }
$winget_package_matrix=@{"git" = "Git.Git"; "nvim" = "Neovim.Neovim"; "make" = "GnuWin32.Make"; "node" = "OpenJS.NodeJS"; "pip" = "Python.Python.3"} $winget_package_matrix=@{"git" = "Git.Git"; "nvim" = "Neovim.Neovim"; "make" = "GnuWin32.Make"; "node" = "OpenJS.NodeJS"; "pip" = "Python.Python.3.11"}
$scoop_package_matrix=@{"git" = "git"; "nvim" = "neovim-nightly"; "make" = "make"; "node" = "nodejs"; "pip" = "python3"} $winget_additional_arguments_matrix=@{"git" = "--source winget --interactive"; "nvim" = "--interactive"; "make" = "--interactive"; "node" = ""; "pip" = ""}
$scoop_package_matrix=@{"git" = "git"; "nvim" = "neovim"; "make" = "make"; "node" = "nodejs"; "pip" = "python"}
function install_system_package($dep) { function install_system_package($dep) {
# Make installers sometimes have a problem when adding make to path
Write-Output "WARNING: Preparing 'make' installation. The make directory ('C:\Program Files (x86)\GnuWin32\bin') might not be added to the PATH by the installer, and you might have to manually to the PATH!"
if (Get-Command -Name "winget" -ErrorAction SilentlyContinue) { if (Get-Command -Name "winget" -ErrorAction SilentlyContinue) {
Write-Output "Attempting to install dependency [$dep] with winget" Write-Output "Attempting to install dependency [$dep] with winget"
$install_cmd = "winget install --interactive $winget_package_matrix[$dep]"
$command="winget"
$command_arguments = "-e --id $($winget_package_matrix[$dep]) $($winget_additional_arguments_matrix[$dep])".Trim() -split ' '
} }
elseif (Get-Command -Name "scoop" -ErrorAction SilentlyContinue) { elseif (Get-Command -Name "scoop" -ErrorAction SilentlyContinue) {
Write-Output "Attempting to install dependency [$dep] with scoop" Write-Output "Attempting to install dependency [$dep] with scoop"
# TODO: check if it's fine to not run it with --global # TODO: check if it's fine to not run it with --global
$install_cmd = "scoop install $scoop_package_matrix[$dep]" $command = "scoop"
$command_arguments = "$($scoop_package_matrix[$dep])".Trim() -split ' '
} }
else { else {
print_missing_dep_msg "$dep" print_missing_dep_msg "$dep"
@ -104,10 +111,11 @@ function install_system_package($dep) {
} }
try { try {
Invoke-Command $install_cmd -ErrorAction Stop & $command install $command_arguments
} # Refresh the path after installation
catch { $env:Path = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path", "User")
print_missing_dep_msg "$dep" } catch {
Write-Output "An error occurred: $_"
exit 1 exit 1
} }
} }