ServerKit is a lightweight, modern server control panel for managing web applications, databases, and services on your VPS or dedicated server. Built with Python/Flask backend and React frontend.
Python astracloudflarecontrol-panelcyberpaneldnsfablehosting-control-panelhosting-panelkimi-k3server-managementserverkitubuntu-web-panelwebserver
fix(dev): pin the WSL distro dev.ps1 launches into
Juan Denisda8efcebf003
diff --git a/dev.ps1 b/dev.ps1index 0ac908d8..10f3110f 100644--- a/dev.ps1+++ b/dev.ps1@@ -5,12 +5,19 @@.DESCRIPTIONDelegates to dev/dev.sh through WSL so local development runs in aLinux-like environment and stays in sync with the Bash launcher.++ With several distros installed, the launcher picks the first one that has a+ real Linux node (not the Windows shim reached through PATH interop) rather+ than trusting the current WSL default. Set SERVERKIT_WSL_DISTRO to override..EXAMPLE.\dev.ps1Start backend + frontend through WSL on stable non-default ports..EXAMPLE.\dev.ps1 frontend -BackendPort 5600Start Vite through WSL, targeting an existing backend on port 5600.+.EXAMPLE+ $env:SERVERKIT_WSL_DISTRO = 'Ubuntu-22.04'; .\dev.ps1+ Force a specific distro instead of auto-detecting one.#>$ProjectRoot = $PSScriptRoot@@ -21,7 +28,59 @@ if (-not (Get-Command wsl.exe -ErrorAction SilentlyContinue)) {exit 1}-$wslRoot = (& wsl.exe --exec wslpath -a -u "$ProjectRoot" 2>$null)+# Which distro to run in. Pinning this matters on machines with more than one:+# a distro without a Linux node/npm silently falls through WSL's PATH interop to+# the Windows node shim under /mnt/c, which then fails with messages that read+# like a WSL problem ("WSL 1 is not supported", "Could not determine Node.js+# install directory") rather than "node isn't installed here". So prefer a+# distro that actually has node, instead of trusting whichever one happens to be+# the current default.+function Get-WslDistros {+ # `wsl -l -q` emits UTF-16LE; decode explicitly or every name arrives with+ # NUL bytes interleaved.+ $prevEncoding = [Console]::OutputEncoding+ try {+ [Console]::OutputEncoding = [System.Text.Encoding]::Unicode+ return (& wsl.exe -l -q) |+ ForEach-Object { $_.Trim() } |+ Where-Object { $_ -and $_ -ne 'docker-desktop' -and $_ -ne 'docker-desktop-data' }+ } finally {+ [Console]::OutputEncoding = $prevEncoding+ }+}++function Test-DistroHasNode {+ param([string]$Distro)+ # `command -v node` alone is not enough: PATH interop makes the Windows+ # shim answer. Require the resolved path to be a real Linux one.+ #+ # The probe can emit several lines (a failing Windows shim prints its own+ # errors), so scan every line for one absolute Linux path rather than+ # assuming a single-string result.+ $lines = @(& wsl.exe -d $Distro --exec bash -lc 'command -v node 2>/dev/null' 2>$null)+ foreach ($line in $lines) {+ $path = "$line".Trim()+ if ($path.StartsWith('/') -and -not $path.StartsWith('/mnt/')) { return $true }+ }+ return $false+}++function Resolve-DevDistro {+ if ($env:SERVERKIT_WSL_DISTRO) { return $env:SERVERKIT_WSL_DISTRO }++ $distros = @(Get-WslDistros)+ if ($distros.Count -le 1) { return $null } # nothing to choose between++ foreach ($d in $distros) {+ if (Test-DistroHasNode -Distro $d) { return $d }+ }+ return $null+}++$distro = Resolve-DevDistro+$distroArgs = if ($distro) { @('-d', $distro) } else { @() }++$wslRoot = (& wsl.exe @distroArgs --exec wslpath -a -u "$ProjectRoot" 2>$null)if ($LASTEXITCODE -ne 0 -or -not $wslRoot) {Write-Host "Error: Could not map this Windows path into WSL: $ProjectRoot" -ForegroundColor RedWrite-Host "Make sure a WSL distro is installed and can access this repository." -ForegroundColor Yellow@@ -108,6 +167,10 @@ foreach ($name in @('SERVERKIT_BACKEND_PORT', 'SERVERKIT_FRONTEND_PORT', 'SERVER}}-Write-Host "Launching ServerKit dev environment in WSL..." -ForegroundColor Cyan-& wsl.exe --cd "$wslRoot" --exec env @forwardedEnv bash ./dev/dev.sh @devArgs+if ($distro) {+ Write-Host "Launching ServerKit dev environment in WSL ($distro)..." -ForegroundColor Cyan+} else {+ Write-Host "Launching ServerKit dev environment in WSL..." -ForegroundColor Cyan+}+& wsl.exe @distroArgs --cd "$wslRoot" --exec env @forwardedEnv bash ./dev/dev.sh @devArgsexit $LASTEXITCODE