fix: auto-start local adb daemon and optimize path discovery across Linux, macOS and Windows

This commit is contained in:
somew1nd committed 2026-09-04 12:01:32 -07:00
1 parent 8b3cfe9bb3
commit 41b1b94706
7 files changed
+114

No files matched your search

+25
View File
@@ -39,7 +39,9 @@ function Update-EnvironmentPath {
$standardDirs = @(
"$env:LOCALAPPDATA\Microsoft\WinGet\Links",
"$env:LOCALAPPDATA\Android\Sdk\platform-tools",
"$env:LOCALAPPDATA\Android\android-sdk\platform-tools",
"$env:ProgramFiles\Android\platform-tools",
"${env:ProgramFiles(x86)}\Android\android-sdk\platform-tools",
"$env:ProgramFiles\nodejs",
"${env:ProgramFiles(x86)}\nodejs",
"$env:APPDATA\npm",
@@ -47,16 +49,34 @@ function Update-EnvironmentPath {
"$env:LOCALAPPDATA\Programs\node",
"$env:USERPROFILE\.local\share\platform-tools",
"$env:USERPROFILE\.local\share\node",
"$env:LOCALAPPDATA\nvm",
"$env:ProgramData\nvm",
"C:\ProgramData\chocolatey\bin",
"$env:USERPROFILE\scoop\shims",
"$env:USERPROFILE\.local\bin",
"$env:USERPROFILE\.cargo\bin"
)
if ($env:ANDROID_HOME) { $standardDirs += "$env:ANDROID_HOME\platform-tools" }
if ($env:ANDROID_SDK_ROOT) { $standardDirs += "$env:ANDROID_SDK_ROOT\platform-tools" }
if ($env:NVM_HOME) { $standardDirs += $env:NVM_HOME }
if ($env:NVM_SYMLINK) { $standardDirs += $env:NVM_SYMLINK }
$regPath = [Environment]::GetEnvironmentVariable("Path", "User") + ";" + [Environment]::GetEnvironmentVariable("Path", "Machine")
$currentPaths = ($env:PATH -split ";") + ($regPath -split ";") + $standardDirs | Where-Object { [string]::IsNullOrWhiteSpace($_) -eq $false -and (Test-Path $_) } | Select-Object -Unique
$env:PATH = $currentPaths -join ";"
}
function Start-LocalAdbServer {
if (Test-CommandExists "adb") {
try {
$origSocket = $env:ADB_SERVER_SOCKET
Remove-Item Env:\ADB_SERVER_SOCKET -ErrorAction SilentlyContinue
& adb start-server 2>$null | Out-Null
if ($origSocket) { $env:ADB_SERVER_SOCKET = $origSocket }
} catch {}
}
}
function Test-CommandExists {
param([string]$Command)
$res = Get-Command $Command -ErrorAction SilentlyContinue
@@ -132,6 +152,7 @@ if (-not (Test-CommandExists "scrcpy")) { $missingTools += "scrcpy" }
if ($missingTools.Count -eq 0) {
Write-Host " ✔ All system toolchains are already installed (ADB, FFmpeg, scrcpy)." -ForegroundColor Green
Start-LocalAdbServer
} else {
Write-Host " ! Missing toolchains: $($missingTools -join ', ')" -ForegroundColor DarkYellow
$useWinGet = $false
@@ -175,6 +196,9 @@ if ($missingTools.Count -eq 0) {
if (-not (Test-CommandExists "adb")) {
Install-PortablePlatformTools
}
# Ensure local ADB daemon is warm & listening
Start-LocalAdbServer
}
# 2. Check and Install uv (Fast Python Package Manager)
@@ -285,6 +309,7 @@ Write-Host " ✨ Artemis Environment Ready! " -Foreground
Write-Host "======================================================" -ForegroundColor Cyan
if ($Launch -or $Open) {
Start-LocalAdbServer
Write-Host "🚀 Launching Showcase UI..." -ForegroundColor Green
uv run artemis ui --open
} else {
+24
View File
@@ -127,12 +127,31 @@ install_system_packages() {
local need_ffmpeg=false
local need_scrcpy=false
if ! has_cmd adb; then
for candidate in \
"${ANDROID_HOME:-}/platform-tools" \
"${ANDROID_SDK_ROOT:-}/platform-tools" \
"${HOME}/Library/Android/sdk/platform-tools" \
"${HOME}/Android/Sdk/platform-tools" \
"${HOME}/.local/share/platform-tools" \
"/opt/homebrew/bin" \
"/usr/local/bin"; do
if [ -n "${candidate}" ] && [ -x "${candidate}/adb" ]; then
export PATH="${candidate}:${PATH}"
break
fi
done
fi
if ! has_cmd adb; then need_adb=true; fi
if ! has_cmd ffmpeg; then need_ffmpeg=true; fi
if ! has_cmd scrcpy; then need_scrcpy=true; fi
if [ "${need_adb}" = false ] && [ "${need_ffmpeg}" = false ] && [ "${need_scrcpy}" = false ]; then
echo -e " ${GREEN}✓ All core system tools are already installed.${NC}"
if has_cmd adb; then
(unset ADB_SERVER_SOCKET; adb start-server >/dev/null 2>&1 || true)
fi
return 0
fi
@@ -234,6 +253,11 @@ install_system_packages() {
fi
fi
fi
# Ensure local ADB daemon is warm & listening
if has_cmd adb; then
(unset ADB_SERVER_SOCKET; adb start-server >/dev/null 2>&1 || true)
fi
}
# Function to ensure uv is installed and ready
+26
View File
@@ -34,7 +34,9 @@ function Update-EnvironmentPath {
$standardDirs = @(
"$env:LOCALAPPDATA\Microsoft\WinGet\Links",
"$env:LOCALAPPDATA\Android\Sdk\platform-tools",
"$env:LOCALAPPDATA\Android\android-sdk\platform-tools",
"$env:ProgramFiles\Android\platform-tools",
"${env:ProgramFiles(x86)}\Android\android-sdk\platform-tools",
"$env:ProgramFiles\nodejs",
"${env:ProgramFiles(x86)}\nodejs",
"$env:APPDATA\npm",
@@ -42,16 +44,34 @@ function Update-EnvironmentPath {
"$env:LOCALAPPDATA\Programs\node",
"$env:USERPROFILE\.local\share\platform-tools",
"$env:USERPROFILE\.local\share\node",
"$env:LOCALAPPDATA\nvm",
"$env:ProgramData\nvm",
"C:\ProgramData\chocolatey\bin",
"$env:USERPROFILE\scoop\shims",
"$env:USERPROFILE\.local\bin",
"$env:USERPROFILE\.cargo\bin"
)
if ($env:ANDROID_HOME) { $standardDirs += "$env:ANDROID_HOME\platform-tools" }
if ($env:ANDROID_SDK_ROOT) { $standardDirs += "$env:ANDROID_SDK_ROOT\platform-tools" }
if ($env:NVM_HOME) { $standardDirs += $env:NVM_HOME }
if ($env:NVM_SYMLINK) { $standardDirs += $env:NVM_SYMLINK }
$regPath = [Environment]::GetEnvironmentVariable("Path", "User") + ";" + [Environment]::GetEnvironmentVariable("Path", "Machine")
$currentPaths = ($env:PATH -split ";") + ($regPath -split ";") + $standardDirs | Where-Object { [string]::IsNullOrWhiteSpace($_) -eq $false -and (Test-Path $_) } | Select-Object -Unique
$env:PATH = $currentPaths -join ";"
}
function Start-LocalAdbServer {
if (Test-CommandExists "adb") {
try {
$origSocket = $env:ADB_SERVER_SOCKET
Remove-Item Env:\ADB_SERVER_SOCKET -ErrorAction SilentlyContinue
& adb start-server 2>$null | Out-Null
if ($origSocket) { $env:ADB_SERVER_SOCKET = $origSocket }
} catch {}
}
}
function Test-CommandExists {
param([string]$Command)
$res = Get-Command $Command -ErrorAction SilentlyContinue
@@ -164,6 +184,9 @@ if ($missingCore.Count -gt 0) {
}
}
# Ensure local ADB daemon is warm & listening so probes do not hit 'Connection refused'
Start-LocalAdbServer
# 4. Check or initialize .env
if (-not (Test-Path ".env")) {
if (Test-Path ".env.example") {
@@ -259,6 +282,9 @@ if ($installMcp -match "^[Yy]") {
Write-Host ""
# 8. Launch unified Showcase UI & open browser
# Ensure local ADB daemon is warm & listening
Start-LocalAdbServer
# Launch via `python -m artemis` (not the `artemis.exe` console-script shim) so the
# long-running server never locks .venv\Scripts\artemis.exe against `uv sync` reinstalls.
Write-Host " [INFO] Launching Artemis Showcase UI & Admin Console..." -ForegroundColor Green