microsoft / microsoft/apm

[BUG] install --dry-run falsely previews removal of a required transitive dependency

Open
#3,035 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
3.8k
Forks
362
Avg merge
1d 17h
Merged PRs (30d)
132

Description

Describe the bug

After a package with a transitive dependency is installed, rerunning apm install --dry-run from the unchanged consumer manifest omits the transitive package from its dependency preview and incorrectly says the transitive package's deployed files would be removed.

Running the same command without --dry-run resolves both packages and preserves the transitive files.

To Reproduce

  1. Create three sibling directories named consumer, parent, and child.

  2. Create consumer/apm.yml:

    name: consumer
    version: 1.0.0
    targets:
      - copilot
    dependencies:
      apm:
        - ../parent
    
  3. Create parent/apm.yml:

    name: parent
    version: 1.0.0
    dependencies:
      apm:
        - ../child
    
  4. Create child/apm.yml:

    name: child
    version: 1.0.0
    
  5. Add this instruction at both parent/.apm/instructions/parent.instructions.md and child/.apm/instructions/child.instructions.md:

    ---
    applyTo: "**"
    ---
    # Instruction
    
  6. From consumer, run apm install --target copilot. Both packages are installed:

    [+] ../parent (local)
    [+] ../child (local)
    [*] Installed 2 APM dependencies
    
  7. Without changing any manifest, run apm install --target copilot --dry-run:

    [i] APM dependencies (1):
    [i]   - ../parent -> install
    [i] Files that would be removed (packages no longer in apm.yml): 1
    [i]   - .github/instructions/child.instructions.md
    
  8. Run apm install --target copilot without --dry-run. It resolves both packages and leaves the child instruction unchanged.

Expected behavior

Dry-run reflects the real install plan: it includes the still-required transitive package and does not preview removal of its deployed files.

Environment (please complete the following information):

  • OS: macOS
  • Python Version: 3.14.7
  • APM Version: 0.31.0 installed with Homebrew; also reproduced with current main
  • VSCode Version (if relevant): Not applicable

Logs

The relevant output is included in the reproduction above.

Additional context

The dry-run plan collects only the root package's direct and development dependencies and uses those dependencies as its orphan-preview intent. The renderer passes that set to detect_orphans and labels the result as files that would be removed because packages are no longer in apm.yml.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the three-package scenario with apm install --target copilot followed by apm install --target copilot --dry-run. Read src/apm_cli/install/dry_run_plan.py at the dependency collection and orphan-preview sections, then inspect src/apm_cli/install/presentation/dry_run.py where the result is rendered. Done means dry-run includes the required transitive package and no longer previews its files for removal.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
76/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.