Skip to content

Fix PowerShell $PID variable conflict in start-lemonade.ps1#331

Merged
kovtcharov-amd merged 14 commits intomainfrom
fix/powershell-pid-variable-conflict
Feb 10, 2026
Merged

Fix PowerShell $PID variable conflict in start-lemonade.ps1#331
kovtcharov-amd merged 14 commits intomainfrom
fix/powershell-pid-variable-conflict

Conversation

@kovtcharov
Copy link
Collaborator

@kovtcharov kovtcharov commented Feb 9, 2026

Summary

Fixes CI test failure on machines with stricter PowerShell configurations by renaming a variable that conflicted with PowerShell's read-only $PID automatic variable.

Problem

The lemonade smoke test was failing on one specific machine with:

Error: Cannot overwrite variable PID because it is read-only or constant.

The script used $pid (line 69) to store a process ID during port availability checking. PowerShell's $PID is a read-only automatic variable (current process ID), and PowerShell variable names are case-insensitive, so $pid and $PID refer to the same variable.

Solution

Renamed $pid$processId to avoid the conflict.

Testing

  • Local testing: Script runs without errors
  • CI testing: Needs verification on stx-test machine

Impact

  • Low risk: Simple variable rename in error handling code
  • Fixes intermittent CI failures on machines with stricter PowerShell enforcement
  • No functional changes to the script behavior

🤖 Generated with Claude Code

Changed variable name from $pid to $processId to avoid conflict with
PowerShell's read-only automatic variable $PID. This was causing
"Cannot overwrite variable PID" errors on machines with stricter
PowerShell configurations, leading to CI test failures.

The functional tests passed but the script returned exit code 1 due
to this early error during port availability checking.

Co-Authored-By: Claude Sonnet 4.5 (1M context) <[email protected]>
Enable label-based runner selection for lemonade smoke test.
When a PR has the 'stx-test' label, it will run on the stx-test
machine instead of the default stx runner.

Co-Authored-By: Claude Sonnet 4.5 (1M context) <[email protected]>
@kovtcharov kovtcharov added the stx-test Run CI on stx-test machine label Feb 9, 2026
@github-actions github-actions bot added the devops DevOps/infrastructure changes label Feb 9, 2026
Extended the stx-test label-based runner selection to all 6 remaining
workflows that use stx runners:
- test_api.yml
- test_chat_sdk.yml
- test_embeddings.yml
- test_gaia_cli_windows.yml
- test_rag.yml
- test_sd.yml

Now any PR with the 'stx-test' label will run all CI workflows on the
stx-test machine instead of the default stx runner. This provides
consistent testing infrastructure across all workflows.

Co-Authored-By: Claude Sonnet 4.5 (1M context) <[email protected]>
@kovtcharov kovtcharov requested a review from vgodsoe February 9, 2026 22:34
@kovtcharov kovtcharov self-assigned this Feb 9, 2026
@kovtcharov kovtcharov added this to the v0.15.4 milestone Feb 9, 2026
Claude Code and others added 10 commits February 9, 2026 14:36
When multiple connections exist on the same port (e.g., IPv4 and IPv6),
Get-NetTCPConnection returns an array. This caused the PID to be
displayed multiple times (e.g., "9152 9152") and potentially failed
to kill all processes properly.

Now we extract unique PIDs and kill each one individually.

Co-Authored-By: Claude Sonnet 4.5 (1M context) <[email protected]>
The test_lemonade_server.yml workflow was missing the install-lemonade
action that verifies lemonade-server is pre-installed on the runner.
This caused the script to fail with "lemonade-server not found" error.

All other workflows (test_api, test_chat_sdk, test_embeddings,
test_gaia_cli_windows, test_rag) include this verification step.

The install-lemonade action:
- Verifies lemonade-server exists on PATH
- Checks version compatibility with GAIA
- Exports LEMONADE_SERVER_PATH environment variable

Co-Authored-By: Claude Sonnet 4.5 (1M context) <[email protected]>
The action previously only checked if lemonade-server was in PATH,
which fails when it's installed but not added to system PATH.

Now the action:
1. First checks PATH (fast path for properly configured runners)
2. If not found, searches common Windows installation locations:
   - %LOCALAPPDATA%\Programs\Lemonade
   - %ProgramFiles%\Lemonade
   - %ProgramFiles(x86)%\Lemonade
   - %USERPROFILE%\Lemonade
   - %LOCALAPPDATA%\Lemonade
3. Automatically adds found directory to GITHUB_PATH for the job
4. Provides clear error with searched paths if not found

This makes the action more robust for self-hosted runners where
lemonade-server may be installed without being in system PATH.

Co-Authored-By: Claude Sonnet 4.5 (1M context) <[email protected]>
Added the actual installation path used on CI runners:
- C:\Program Files (x86)\Lemonade Server\bin

This path is now checked first to ensure fast discovery on
self-hosted runners with the standard Lemonade Server installation.

Co-Authored-By: Claude Sonnet 4.5 (1M context) <[email protected]>
GitHub Actions self-hosted runners run as a service and may not
inherit updated System/User PATH variables until service restart.

Changes:
- Added PATH debugging to diagnose environment issues
- Proactively add known stx runner path (C:\Program Files (x86)\Lemonade Server\bin) to session PATH
- Check PATH again after addition before falling back to search

This ensures lemonade-server is found even when runner service
hasn't been restarted after PATH updates.

Co-Authored-By: Claude Sonnet 4.5 (1M context) <[email protected]>
Enhanced diagnostics to troubleshoot why lemonade-server with space
in path ("Lemonade Server") is not found despite being in PATH.

Now shows:
- System PATH from registry
- User PATH from registry
- Current session PATH (what runner actually sees)
- Filtered view of Lemonade-related paths
- Explicit check if lemonade-server.exe exists at known location

This will reveal if:
- Space in path causes parsing issues
- Runner service inherits PATH correctly
- GITHUB_PATH addition works properly

Co-Authored-By: Claude Sonnet 4.5 (1M context) <[email protected]>
Removed extensive debug output while keeping working logic:
- Proactively check and add known installation path to PATH
- Fallback to searching common locations if needed
- Minimal, clear output focused on operational info

The action now efficiently handles self-hosted runners where
lemonade-server PATH may not be inherited by runner service.

Co-Authored-By: Claude Sonnet 4.5 (1M context) <[email protected]>
Re-added ${env:ProgramFiles(x86)}\Lemonade Server\bin to the
fallback search paths array. While this path is checked proactively
at the top, keeping it in the fallback ensures redundancy.

Co-Authored-By: Claude Sonnet 4.5 (1M context) <[email protected]>
The stx runner path is already checked proactively at the top and
added to PATH if it exists. Checking it again in the fallback is
redundant - if it existed, we would have already found it.

Fallback now only searches alternative locations that weren't
checked in the initial known-path logic.

Co-Authored-By: Claude Sonnet 4.5 (1M context) <[email protected]>
Now clearly communicates:
- "Found at known location" vs "Not found at known location"
- "Adding to PATH" vs "Already in PATH"
- "lemonade-server not found in PATH, searching alternatives..."
- "Found at alternative location" when using fallback

Makes the CI logs easier to understand and debug.

Co-Authored-By: Claude Sonnet 4.5 (1M context) <[email protected]>
Unified the logic into one clean flow:
1. Check if already in PATH
2. If not found, search common locations (one loop)
3. Print where found and add to PATH
4. Verify availability

Removes redundant checks and special-casing. Cleaner and easier
to maintain.

Co-Authored-By: Claude Sonnet 4.5 (1M context) <[email protected]>
@kovtcharov-amd kovtcharov-amd added this pull request to the merge queue Feb 9, 2026
Merged via the queue into main with commit b209074 Feb 10, 2026
47 checks passed
@kovtcharov-amd kovtcharov-amd deleted the fix/powershell-pid-variable-conflict branch February 10, 2026 00:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

devops DevOps/infrastructure changes stx-test Run CI on stx-test machine

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants