Skip to content

fix(run): prioritize APM-managed runtimes and pin codex compatibility (#605)#651

Closed
sergio-sisternes-epam wants to merge 4 commits intomicrosoft:mainfrom
sergio-sisternes-epam:fix/605-runtime-detection
Closed

fix(run): prioritize APM-managed runtimes and pin codex compatibility (#605)#651
sergio-sisternes-epam wants to merge 4 commits intomicrosoft:mainfrom
sergio-sisternes-epam:fix/605-runtime-detection

Conversation

@sergio-sisternes-epam
Copy link
Copy Markdown
Collaborator

@sergio-sisternes-epam sergio-sisternes-epam commented Apr 9, 2026

Summary

Fixes runtime detection priority so APM-managed binaries in ~/.apm/runtimes/ are checked before system PATH. Also fixes Windows .exe detection.

Closes #605.

Changes

src/apm_cli/core/script_runner.py

  • _detect_installed_runtime() now uses shutil.which(name, path=str(runtime_dir)) to check ~/.apm/runtimes/ before falling back to system PATH
  • Windows: checks for {name}.exe in runtimes dir when shutil.which fails

Tests

  • TestDetectInstalledRuntime class with 7 test cases including Windows .exe scenario

CHANGELOG

  • Entry under ### Fixed in [Unreleased]

Closing in favor of #608, which covers the same #605 fix plus additional runtime improvements. The core detection priority fix is equivalent.

…microsoft#605)

- _detect_installed_runtime() now checks ~/.apm/runtimes/ before system
  PATH, preventing system stubs from shadowing APM-managed binaries
- Pin codex setup scripts to v0.1.2025051600 (last version supporting
  wire_api="chat" for GitHub Models compatibility)
- Add warnings in codex setup scripts about GitHub Models limitation
- Add 6 unit tests covering runtime detection priority scenarios

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 9, 2026 17:26
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes apm run start runtime selection by prioritizing APM-managed runtimes over system PATH lookups, and pins the Codex runtime installer to a GitHub Models-compatible Codex version to avoid breaking API incompatibilities.

Changes:

  • Update _detect_installed_runtime() to check ~/.apm/runtimes/ before using shutil.which() on PATH.
  • Pin Codex setup scripts (bash + PowerShell) to 0.1.2025051600 and add compatibility warnings for GitHub Models.
  • Add unit tests covering the new runtime detection priority logic.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/apm_cli/core/script_runner.py Implements APM-managed runtime precedence over PATH during runtime detection.
tests/unit/test_script_runner.py Adds unit tests for runtime detection priority behavior.
scripts/runtime/setup-codex.sh Pins default Codex version and logs warnings about GitHub Models compatibility.
scripts/runtime/setup-codex.ps1 Pins default Codex version and logs warnings about GitHub Models compatibility on Windows.
CHANGELOG.md Adds Unreleased “Fixed” entries describing the runtime detection change and Codex pin.

Sergio Sisternes and others added 2 commits April 9, 2026 19:33
…icrosoft#605)

- Use shutil.which(name, path=runtime_dir) for APM-managed runtime
  detection, handling .exe suffix on Windows via PATHEXT automatically
- Add test for Windows .exe binary detection in APM runtimes dir
- Update changelog entries to reference PR microsoft#651

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@sergio-sisternes-epam
Copy link
Copy Markdown
Collaborator Author

CI Integration Failure — Root Cause Analysis

Failing job

Integration Tests (Linux) — step "Setting up Codex runtime"

Root cause

The codex setup script pins CODEX_VERSION="0.1.2025051600", but the OpenAI/codex project deleted all old-format release tags. Only rust-v* tags remain. The download URL returns a 404 HTML page, and tar -xzf fails with gzip: stdin: not in gzip format.

Additional discovery

  • wire_api="chat" no longer exists in ANY available Codex release (checked v0.100 through v0.118). The config schema only supports wire_api = "responses".
  • The original pin rationale (GitHub Models chat wire API compatibility) is moot — that protocol was removed from Codex entirely.

Fix plan

  • Pin to rust-v0.118.0 (latest stable, non-alpha release) — verified assets exist and are downloadable
  • Update wire_api from "chat" to "responses" in the generated Codex config
  • Update both .sh and .ps1 setup scripts
  • Keep version pinning (no "latest") for security and reproducibility

The codex version pin (0.1.2025051600) references a deleted tag — the
openai/codex project removed all old-format releases. This caused CI
integration tests to fail (tar receives an HTML 404 page instead of a
binary).

Revert setup-codex.sh and setup-codex.ps1 to main's CODEX_VERSION=latest
to unblock this PR. The version pinning concern will be addressed in a
separate issue and PR.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: apm run start picks wrong runtime — system PATH stub takes priority over APM-managed binary, codex v0.116+ incompatible with GitHub Models

2 participants