Skip to content

fix: clear error on remove with suggestions for missing dependency#6218

Merged
ruben-arts merged 1 commit into
prefix-dev:mainfrom
baszalmstra:claude/optimistic-pascal-i3Q8i
May 28, 2026
Merged

fix: clear error on remove with suggestions for missing dependency#6218
ruben-arts merged 1 commit into
prefix-dev:mainfrom
baszalmstra:claude/optimistic-pascal-i3Q8i

Conversation

@baszalmstra
Copy link
Copy Markdown
Contributor

@baszalmstra baszalmstra commented May 26, 2026

Description

pixi remove <name> used to print a misleading "doesn't exist" warning followed by a green success line, even when the dependency lived in a different table (for example [pypi-dependencies] instead of [dependencies]) and nothing was actually removed.

It now fails with a clear error and a help message that points the user at the right place:

$ pixi remove polars
Error:   x dependency `polars` was not found in dependencies
  help: `polars` is a pypi-dependencies entry in the default feature; try
        `pixi remove --pypi polars`

$ pixi remove --pypi polrs
Error:   x dependency `polrs` was not found in pypi-dependencies
  help: did you mean `polars`?

$ pixi remove numpy
Error:   x dependency `numpy` was not found in dependencies
  help: `numpy` is a dependencies entry in feature `dev`; try
        `pixi remove --feature dev numpy`

The success line is only printed when something was actually removed.

Fixes #3144

How Has This Been Tested?

  • New inline snapshot tests in pixi_cli cover each suggestion edge case (wrong dep type, wrong feature, host/build tables, typos, absent name) plus the rendered RemoveError variants (not-found, python guard, save failure).
  • Existing pixi_manifest unit tests still pass.
  • cargo fmt and cargo clippy are clean on the touched crates.
  • Manually verified with a debug build against the original repro from Pixi warns that PyPI dependency doesn't exist before removing it #3144.

AI Disclosure

  • This PR contains AI-generated content.
    • I have tested any AI-generated content in my PR.
    • I take responsibility for any AI-generated content in my PR.

Tools: Claude Code

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added sufficient tests to cover my changes.

`pixi remove <name>` used to print "doesn't exist" as a tracing warning
and then unconditionally show a green success line, even when the
dependency lived in a different table (`[pypi-dependencies]`, another
feature, a host/build section) and nothing was actually removed.

It now fails with a typed error and a help message that points at the
right place:

  $ pixi remove polars
  Error:   x dependency `polars` was not found in dependencies
    help: `polars` is a pypi-dependencies entry in the default feature; try
          `pixi remove --pypi polars`

  $ pixi remove --pypi polrs
  Error:   x dependency `polrs` was not found in pypi-dependencies
    help: did you mean `polars`?

  $ pixi remove numpy
  Error:   x dependency `numpy` was not found in dependencies
    help: `numpy` is a dependencies entry in feature `dev`; try
          `pixi remove --feature dev numpy`

The success line is only printed when something is actually removed.

The API surface is typed end-to-end: `Workspace::remove_dependency` /
`remove_pypi_dependency` return `RemoveDependencyError`, and the
`pixi_api` `remove_conda_deps` / `remove_pypi_deps` entry points return
a `RemoveError` enum with concrete variants per failure source
(`NotFound`, `PythonHasPypiDependencies`, `LoadWorkspace`, `Manifest`,
`Save`, `LockFileUpdate`). The CLI pattern-matches the typed result
and builds a `DependencyRemovalError` diagnostic for the `NotFound`
arm, with suggestions computed from the workspace manifest.

Adds inline-snapshot tests covering each suggestion edge case (wrong
dep type, wrong feature, host/build tables, typos, absent name) plus
tokio-driven tests that exercise the python guard and the not-found
path through the real API.

Fixes prefix-dev#3144
@baszalmstra baszalmstra requested a review from ruben-arts May 26, 2026 15:09
Copy link
Copy Markdown
Contributor

@ruben-arts ruben-arts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good improvement, I have some other ideas which I will write up in a different issue.

@ruben-arts ruben-arts merged commit 1126af8 into prefix-dev:main May 28, 2026
38 checks passed
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.

Pixi warns that PyPI dependency doesn't exist before removing it

3 participants