Skip to content

vp uninstall -g should succeed (exit 0) when package is not installed, matching npm behavior #2327

Description

@ywenhao

Description

When a globally installed package is not present, vp uninstall -g <pkg> exits with a non-zero status and prints an error. This breaks common shell patterns such as:

vp uninstall -g corepack && vp install -g <pkg>

The && chain stops after the uninstall step, so the subsequent install never runs.

npm uninstall -g does not exhibit this behavior — uninstalling a package that is not installed succeeds with exit code 0, allowing idempotent uninstall-then-install workflows.

Steps to reproduce

  1. Ensure corepack is not listed in global packages:

    vp list -g
  2. Run uninstall:

    vp uninstall -g corepack

    Actual: exits with code 1 and prints:

    Failed to uninstall corepack: Package corepack is not installed
    
  3. Compare with npm:

    npm uninstall -g corepack
    echo $?

    Actual: exits with code 0 (no error).

  4. Chained command fails with vp but works with npm:

    # Fails — second command never runs
    vp uninstall -g corepack && vp install -g typescript
    
    # Works — install runs even if corepack was not installed
    npm uninstall -g corepack && npm install -g typescript

Expected behavior

vp uninstall -g <pkg> should succeed (exit 0) when the package is not installed, consistent with npm. Uninstalling something that is already absent should be a no-op, not an error.

This is especially relevant for packages like corepack that may be managed implicitly by Vite+ (shim / auto-install on Node 25+) and therefore may not appear in vp list -g, yet users still want to run vp uninstall -g corepack defensively before installing another global package.

Environment

  • vp version: v0.2.7
  • OS: Linux (Fedora)
  • Node.js: v24.19.0 (via Vite+)

Metadata

Metadata

Assignees

Fields

Priority

None yet

Start date

None yet

Target date

None yet

Effort

None yet

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions