[BUG] Global apm audit fails when APM_HOME is outside HOME
Describe the bug
A global installation succeeds with an absolute APM_HOME outside HOME, but auditing that installation fails because replay assumes the modules directory is beneath the deployment home.
To Reproduce Run in a disposable shell; the temporary directory is intentionally retained for inspection:
root="$(mktemp -d)"
mkdir -p "$root/home" "$root/work"
export HOME="$root/home" APM_HOME="$root/metadata"
export XDG_CONFIG_HOME="$root/config" XDG_CACHE_HOME="$root/cache"
export XDG_DATA_HOME="$root/data" XDG_STATE_HOME="$root/state"
export CODEX_HOME="$HOME/.codex" CLAUDE_CONFIG_DIR="$HOME/.claude"
export APM_NON_INTERACTIVE=1
cd "$root/work"
apm install --global --target agent-skills 'microsoft/apm/packages/apm-guide/.apm/skills/apm-usage#18c4c43c924ceae890fe0f2038806690e5b2d6c8'
cd "$APM_HOME"
apm audit --ci
The global install exits 0; audit exits 1 with the error below.
Expected behavior
Audit supports an external absolute APM_HOME, consistently with installation, without requiring the metadata directory to be beneath HOME.
Environment (please complete the following information):
- OS: macOS 27.0.1, arm64
- Python Version: N/A — standalone APM binary
- APM Version: 0.36.1
- VSCode Version: N/A
Logs
With the temporary root abbreviated to /tmp/apm-repro:
Error: '/tmp/apm-repro/metadata/apm_modules' is not in the subpath of '/tmp/apm-repro/home'
Additional context Audit replay constructs the modules root using:
get_modules_dir(scope).relative_to(get_deploy_root(scope))
Setting APM_HOME to $HOME/.apm allowed the audit to pass.
Related: #2884 and #3614 established the current APM_HOME behavior; this report concerns the remaining containment assumption in audit replay.
Decision: approve
Area: project
Scope: Make global apm audit (and its replay roots) support an absolute APM_HOME outside HOME. Remove the relative_to assumption in install/audit_target_roots.py that the modules dir sits under the deploy root.
Done when: tests/integration/test_global_audit_deploy_root.py::test_global_audit_supports_absolute_apm_home_outside_home fails on main and passes; APM_HOME under HOME still passes; one CHANGELOG line.
Out of scope: Other APM_HOME relocation behavior; the apm env feature (#3941).
Review contact: @danielmeppiel