fix(install): scope local content scan to ~/.apm/ at user scope (#830)#850
Open
guwenqing wants to merge 3 commits intomicrosoft:mainfrom
Open
fix(install): scope local content scan to ~/.apm/ at user scope (#830)#850guwenqing wants to merge 3 commits intomicrosoft:mainfrom
guwenqing wants to merge 3 commits intomicrosoft:mainfrom
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>
Author
|
@microsoft-github-policy-service agree |
Contributor
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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