From a7fcfc399232f822359ae964479d71237401eed7 Mon Sep 17 00:00:00 2001 From: Aadi Desai <21363892+supleed2@users.noreply.github.com> Date: Mon, 29 May 2023 12:22:51 +0100 Subject: [PATCH 1/3] Add one-liner for installing `cargo-binstall` on Windows --- README.md | 6 ++++++ install-from-binstall-release.ps1 | 20 ++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 install-from-binstall-release.ps1 diff --git a/README.md b/README.md index 28da9e6f9..d9e6552e1 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,12 @@ Here are the one-liners for installing pre-compiled `cargo-binstall` binary from curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash ``` +And the one-liner for installing a pre-compiled `cargo-binstall` binary from release on Windows (x86_64 and aarch64): + +``` +Set-ExecutionPolicy Unrestricted -Scope Process && iex (iwr "https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.ps1").Content +``` + To get started _using_ `cargo-binstall` first install the binary (either via `cargo install cargo-binstall` or by downloading a pre-compiled [release](https://github.com/cargo-bins/cargo-binstall/releases)), then extract it using `tar` or `unzip` and move it into `$HOME/.cargo/bin`. We recommend using the pre-compiled ones because we optimize those more than a standard source build does. diff --git a/install-from-binstall-release.ps1 b/install-from-binstall-release.ps1 new file mode 100644 index 000000000..6d8d291b6 --- /dev/null +++ b/install-from-binstall-release.ps1 @@ -0,0 +1,20 @@ +$tmpdir = $Env:TEMP +$base_url = "https://github.com/cargo-bins/cargo-binstall/releases/latest/download/cargo-binstall-" +$type = (Get-ComputerInfo).CsSystemType.ToLower() +if ($type.StartsWith("x64")) { + $arch = "x86_64" +} elseif ($type.StartsWith("arm64")) { + $arch = "aarch64" +} else { + Write-Host "Unsupported Architecture: $type" -ForegroundColor Red + [Environment]::Exit(1) +} +$url = "$base_url$arch-pc-windows-msvc.zip" +Invoke-WebRequest $url -OutFile $tmpdir\cargo-binstall.zip +Expand-Archive -Force $tmpdir\cargo-binstall.zip $tmpdir\cargo-binstall +Invoke-Expression "$tmpdir\cargo-binstall\cargo-binstall.exe -y --force cargo-binstall" +Remove-Item -Force $tmpdir\cargo-binstall.zip +Remove-Item -Recurse -Force $tmpdir\cargo-binstall +if ($Env:Path -split ";" -notcontains "$HOME\.cargo\bin") { + Write-Host "Your path is missing $HOME\.cargo\bin, you might want to add it." -ForegroundColor Red +} From f2ed7bfc043fb42740c5ae2b97e76dcb3bb5a3ee Mon Sep 17 00:00:00 2001 From: Aadi Desai <21363892+supleed2@users.noreply.github.com> Date: Mon, 29 May 2023 15:38:11 +0100 Subject: [PATCH 2/3] Change command separator to semicolon `&&` was added in Powershell 7 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d9e6552e1..a70ef72f2 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo- And the one-liner for installing a pre-compiled `cargo-binstall` binary from release on Windows (x86_64 and aarch64): ``` -Set-ExecutionPolicy Unrestricted -Scope Process && iex (iwr "https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.ps1").Content +Set-ExecutionPolicy Unrestricted -Scope Process; iex (iwr "https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.ps1").Content ``` To get started _using_ `cargo-binstall` first install the binary (either via `cargo install cargo-binstall` or by downloading a pre-compiled [release](https://github.com/cargo-bins/cargo-binstall/releases)), then extract it using `tar` or `unzip` and move it into `$HOME/.cargo/bin`. From e6a1484b1a94c44791a10f0af4e46629fcd82314 Mon Sep 17 00:00:00 2001 From: Aadi Desai <21363892+supleed2@users.noreply.github.com> Date: Tue, 30 May 2023 13:46:46 +0100 Subject: [PATCH 3/3] Update win install script to exit on error and trace --- install-from-binstall-release.ps1 | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/install-from-binstall-release.ps1 b/install-from-binstall-release.ps1 index 6d8d291b6..f4fad50ca 100644 --- a/install-from-binstall-release.ps1 +++ b/install-from-binstall-release.ps1 @@ -1,3 +1,5 @@ +$ErrorActionPreference = "Stop" +Set-PSDebug -Trace 1 $tmpdir = $Env:TEMP $base_url = "https://github.com/cargo-bins/cargo-binstall/releases/latest/download/cargo-binstall-" $type = (Get-ComputerInfo).CsSystemType.ToLower() @@ -12,9 +14,12 @@ if ($type.StartsWith("x64")) { $url = "$base_url$arch-pc-windows-msvc.zip" Invoke-WebRequest $url -OutFile $tmpdir\cargo-binstall.zip Expand-Archive -Force $tmpdir\cargo-binstall.zip $tmpdir\cargo-binstall +Write-Host "" Invoke-Expression "$tmpdir\cargo-binstall\cargo-binstall.exe -y --force cargo-binstall" Remove-Item -Force $tmpdir\cargo-binstall.zip Remove-Item -Recurse -Force $tmpdir\cargo-binstall if ($Env:Path -split ";" -notcontains "$HOME\.cargo\bin") { + Write-Host "" Write-Host "Your path is missing $HOME\.cargo\bin, you might want to add it." -ForegroundColor Red + Write-Host "" }