From d05fad49a17d82523656d64a2ec82af3c3c7fc3f Mon Sep 17 00:00:00 2001
From: Julian Ospald <hasufell@posteo.de>
Date: Sun, 13 Feb 2022 21:11:48 +0100
Subject: [PATCH] Fix installation with whitespaces in username, fixes #314

---
 scripts/bootstrap/bootstrap-haskell.ps1 | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/scripts/bootstrap/bootstrap-haskell.ps1 b/scripts/bootstrap/bootstrap-haskell.ps1
index 688060f9..b9b9b503 100644
--- a/scripts/bootstrap/bootstrap-haskell.ps1
+++ b/scripts/bootstrap/bootstrap-haskell.ps1
@@ -403,16 +403,17 @@ if (!(Test-Path -Path ('{0}' -f $MsysDir))) {
     # Download the archive
     Print-Msg -msg 'Downloading Msys2 archive...'
     $archive = 'msys2-x86_64-latest.sfx.exe'
+    $archivePath = ('{0}\{1}' -f ([IO.Path]::GetTempPath()), "$archive")
     
     if (Get-Command -Name 'curl.exe' -ErrorAction SilentlyContinue) {
-      Exec "curl.exe" '-o' ('{0}\{1}' -f $env:TEMP, $archive) ('https://repo.msys2.org/distrib/{0}' -f $archive)
+      Exec "curl.exe" '-o' "$archivePath" ('https://repo.msys2.org/distrib/{0}' -f "$archive")
     } else {
-      Get-FileWCSynchronous -url ('https://repo.msys2.org/distrib/{0}' -f $archive) -destinationFolder "$env:TEMP" -includeStats
+      Get-FileWCSynchronous -url ('https://repo.msys2.org/distrib/{0}' -f $archive) -destinationFolder ([IO.Path]::GetTempPath()) -includeStats
     }
 
     Print-Msg -msg 'Extracting Msys2 archive...'
-    $null = & "$env:TEMP\$archive" '-y' ('-o{0}' -f $GhcupDir)  # Extract
-    Remove-Item -Path ('{0}/{1}' -f $env:TEMP, $archive)
+    $null = & "$archivePath" '-y' ('-o{0}' -f $GhcupDir)  # Extract
+    Remove-Item -Path "$archivePath"
 
     Print-Msg -msg 'Processing MSYS2 bash for first time use...'
     Exec "$Bash" '-lc' 'exit'
-- 
GitLab