Skip to content

Commit

Permalink
Merge pull request #303 from saraedum/win-fix
Browse files Browse the repository at this point in the history
Fix invocation on first run on Windows
  • Loading branch information
saraedum authored Sep 25, 2024
2 parents 8e8fdfb + 1c4bc22 commit 918ee7b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
3 changes: 3 additions & 0 deletions doc/news/win-fix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
**Fixed:**

* Fixed startup of SageMath on first invocation on Windows.
29 changes: 13 additions & 16 deletions installer/win/launch.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Launch or Reinstall SageMath
# Launch, Reinstall, or Uninstall SageMath
$ErrorActionPreference = "Stop"

$appDataDir = [System.Environment]::GetFolderPath("LocalApplicationData")
Expand All @@ -14,22 +14,19 @@ function Usage {
}

function EnsureInstalled {
$consoleHandle = (Get-Process -Id $PID).MainWindowHandle

if ($consoleHandle -ne 0) {
if (Test-Path $wsldlExe) {
Write-Output "Not installing, wsldl executable already exists"
return
}

Install
} else {
# Restart script in a visible terminal
Start-Process powershell.exe -ArgumentList @("-File", "`"$PSCommandPath`"", $commandArgs[0]) -Wait
exit
if (Test-Path $wsldlExe) {
Write-Output "Not installing, wsldl executable already exists"
return
}

# Run installer in a visible terminal.
Start-Process powershell.exe -ArgumentList @("-File", "`"$PSCommandPath`"", "--install") -Wait
}

# Creates a VM and installs sage-flatsurf.
# Strangely, this breaks the surrounding PowerShell process.
# It's unclear what's the problem but once this finishes, the actual
# sage-flatsurf won't be able to launch anymore.
function Install {
New-Item -ItemType Directory -Path $localDir -Force > $null
foreach ($fileName in @("sage-flatsurf-VERSION.exe", "preset.json")) {
Expand Down Expand Up @@ -68,6 +65,8 @@ function Install {

& "$wsldlExe" "run" "sh" "-c" "cd ~ && tar zxf sage-flatsurf-VERSION.unix.tar.gz"
Pop-Location

sleep 2
}

function JupyterLab {
Expand Down Expand Up @@ -105,8 +104,6 @@ if ($args.Count -ne 1) {
exit 1
}

$commandArgs = $args

switch ($args[0]) {
'--jupyterlab' {
Write-Output "Launching JupyterLab..."
Expand Down

0 comments on commit 918ee7b

Please sign in to comment.