fix(install): scope local content scan to ~/.apm/ at user scope (#830)#850
Conversation
…osoft#830) At user scope (`--global`), `project_root` is `Path.home()`. `integrate_local_content()` passed this directly as `install_path`, causing `discover_primitives()` to recursive-glob the entire home directory. This caused multi-minute hangs and triggered macOS privacy dialogs (Downloads, Desktop, etc.). Root cause: feature microsoft#626 (local `.apm/` auto-discovery, v0.8.12) was not tested with `-g` where `project_root = ~/` (feature microsoft#452, v0.8.6). Fix: when `scope is InstallScope.USER`, set `install_path` to `project_root / ".apm"` so only `~/.apm/` is scanned. Before: `apm install -g` hangs indefinitely After: `apm install -g` completes in ~4 seconds Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
@microsoft-github-policy-service agree |
There was a problem hiding this comment.
Pull request overview
Fixes a user-scope (apm install -g/--global) performance hang where local primitive discovery could recursively scan the entire home directory by changing how the synthetic “local” package’s scan root is chosen during local-content integration.
Changes:
- Adjust
integrate_local_content()to set the synthetic local packageinstall_path/package_pathto~/.apmwhenscope=InstallScope.USER. - Add a unit test asserting the user-scope synthetic
PackageInfo.install_pathis<project_root>/.apmrather than<project_root>.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/apm_cli/install/services.py |
Changes synthetic local package roots at user scope to avoid scanning $HOME. |
tests/unit/test_local_content_install.py |
Adds coverage asserting the new user-scope install_path behavior. |
…not install_path Address Copilot review feedback: changing install_path to ~/.apm/ broke integrator file discovery (they look under <install_path>/.apm/<type>/). Move the fix to BaseIntegrator.init_link_resolver() instead: when install_path == $HOME, scope discover_primitives() to ~/.apm/ to avoid recursive-globbing the entire home directory. - Revert services.py install_path change (keep project_root) - Fix base_integrator.py init_link_resolver to scope scan root - Update test to verify install_path stays project_root at user scope - Add tests for init_link_resolver home-directory scoping Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
8307ff8 to
de46eb2
Compare
APM Review Panel VerdictDisposition: APPROVE (one required pre-merge action -- see below) PR SummaryFix for issue #830: when a user-scope package has Per-persona findingsPython Architect: The fix is surgical and correctly placed. Kudos for CLI Logging Expert: No output or logging changes. Pass -- nothing to review. DevX UX Expert: No CLI surface changes; fix is fully internal. The performance Supply Chain Security Expert: Constraining the scan scope from Auth Expert: Not applicable -- no auth code touched. OSS Growth Hacker: This removes a silent "APM freezes my terminal on global CEO arbitrationSpecialists are aligned -- no disagreement to arbitrate. This is a well-scoped, Required actions before merge
Optional follow-ups
|
…ob fix Add the required CHANGELOG entry under [Unreleased] per the APM Review Panel verdict on PR microsoft#850. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Thanks for fixing, I ran into this problem as well. |
fix: scope link-resolver discovery to ~/.apm/ at user scope (#830)
Fixes #830
At user scope (--global), project_root is Path.home(). integrate_local_content() passes this as install_path, and BaseIntegrator.init_link_resolver() calls discover_primitives(install_path) — which recursive-globs the entire home directory. This causes multi-minute hangs and triggers macOS privacy dialogs (Downloads, Desktop, etc.).
Root cause: Feature #626 (local .apm/ auto-discovery, v0.8.12) was not tested with -g where project_root = ~/ (feature #452, v0.8.6).
Fix: In BaseIntegrator.init_link_resolver(), when install_path == Path.home(), scope discover_primitives() to ~/.apm/ instead of ~/. This keeps PackageInfo.install_path as project_root so integrators still find primitives at <project_root>/.apm// correctly.
Before: apm install -g hangs indefinitely After: apm install -g completes in ~4 seconds
Changes
Type of change
Testing