Skip to content

fix(uninstall): scan devDependencies.apm so --dev installs can be removed (closes #1549)#1552

Open
danielmeppiel wants to merge 2 commits into
mainfrom
danielmeppiel/fix-uninstall-dev-1549
Open

fix(uninstall): scan devDependencies.apm so --dev installs can be removed (closes #1549)#1552
danielmeppiel wants to merge 2 commits into
mainfrom
danielmeppiel/fix-uninstall-dev-1549

Conversation

@danielmeppiel
Copy link
Copy Markdown
Collaborator

Closes #1549.

Problem

apm install --dev <pkg> writes the package under devDependencies.apm in apm.yml, but apm uninstall <pkg> only reads/writes dependencies.apm. The result is that every dev-installed package reports

[!] <pkg> - not found in apm.yml
[!] No packages found in apm.yml to remove

and the entry leaks forever. There is no way to remove a --dev install short of editing apm.yml by hand.

Fix shape

apm uninstall now scans both dependencies.apm and devDependencies.apm when looking for matches, and writes the package out of whichever section it lives in. Symmetric to install: --dev installs put the entry in devDependencies.apm; uninstall pulls it back out of the same section. Empty devDependencies wrappers that we synthesised purely to satisfy the read are dropped before writing, so manifests for projects that never used --dev stay byte-identical to today.

Tests

New regression trap at tests/unit/test_uninstall_dev_dependencies.py:

  • test_uninstall_removes_package_from_dev_dependencies -- the headline regression: a package recorded under devDependencies.apm is removed end-to-end.
  • test_uninstall_dry_run_finds_dev_dependency -- --dry-run locates the dev entry and leaves apm.yml untouched.
  • test_uninstall_preserves_unrelated_dev_dependency -- removing one dev dep does not touch other dev or prod entries.

Mutation-break gate: deleting the new devDependencies handling makes all three tests fail with the original not found in apm.yml symptom; restoring the fix makes them pass. The full tests/unit/ -k 'uninstall or dev_depend' suite (227 tests) and tests/integration/ uninstall coverage (23 tests) stay green.

How to test

# Reproduce the bug on main
mkdir /tmp/apm-1549 && cd /tmp/apm-1549
apm init
apm install --dev microsoft/apm-sample-package
apm uninstall microsoft/apm-sample-package
# main: '[!] microsoft/apm-sample-package - not found in apm.yml'
# this PR: package is removed from devDependencies.apm cleanly

Validation evidence

  • uv run --extra dev ruff check src/ tests/ -- silent
  • uv run --extra dev ruff format --check src/ tests/ -- silent
  • uv run --extra dev python -m pylint --disable=all --enable=R0801 --min-similarity-lines=10 --fail-on=R0801 src/apm_cli/ -- 10.00/10
  • bash scripts/lint-auth-signals.sh -- clean
  • pytest tests/unit/ -k 'uninstall or dev_depend' -- 227 passed
  • pytest tests/integration/test_uninstall_*.py tests/integration/test_wave5_e2e_coverage.py -k uninstall -- 23 passed, 2 skipped

…oved

apm install --dev <pkg> writes the entry under devDependencies.apm in
apm.yml, but apm uninstall <pkg> only read dependencies.apm. The result
was an unconditional 'not found in apm.yml' warning and the dev entry
leaking forever. Uninstall now scans both sections and writes back to
whichever section the package lived in.

Closes #1549

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 29, 2026 21:08
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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 uninstall so packages installed with apm install --dev can be discovered and removed from devDependencies.apm, addressing issue #1549.

Changes:

  • Extends uninstall dependency scanning to include both production and development APM dependency sections.
  • Updates manifest write-back logic to remove matched packages from the appropriate section.
  • Adds regression tests for uninstalling, dry-running, and preserving unrelated dev dependencies.
Show a summary per file
File Description
src/apm_cli/commands/uninstall/cli.py Adds devDependencies.apm handling during uninstall.
tests/unit/test_uninstall_dev_dependencies.py Adds regression coverage for uninstalling dev dependencies.
CHANGELOG.md Documents the uninstall fix under Unreleased.

Copilot's findings

  • Files reviewed: 3/3 changed files
  • Comments generated: 2

Comment on lines +143 to +146
if package in dev_deps:
dev_deps.remove(package)
elif package in prod_deps:
prod_deps.remove(package)
Comment thread CHANGELOG.md

### Fixed

- `apm uninstall <pkg>` now scans `devDependencies.apm` in addition to `dependencies.apm`, so packages added with `apm install --dev <pkg>` can actually be removed. Previously dev-only entries reported "not found in apm.yml" and leaked forever. (closes #1549, #1552) -- by @aetos382
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] Can’t uninstall devDependencies

2 participants