Skip to content

Feature: sdk clean subcommand #397

@chloe41427

Description

@chloe41427

Feature request

Implement a sdk clean subcommand that removes installed SDK versions no longer referenced by any .sdkmanrc file — i.e., orphaned versions that have accumulated over time.

This is analogous to brew autoremove for SDKMAN! candidates: it identifies versions that are installed but not pinned by any project configuration, and removes them to recover disk space.

Proposed behaviour

  • Scan all .sdkmanrc files found under a configurable base directory (e.g. ~/)
  • Collect the union of all candidate versions referenced
  • Compare against all currently installed versions
  • Prompt the user to confirm removal of any installed versions not referenced by any .sdkmanrc
  • Optionally support a --dry-run flag to list what would be removed without acting
  • Always protect the current default version of each candidate, even if it is not referenced by any .sdkmanrc file — so if .sdkmanrc pins java=21.0.10-tem and the default is 17.0.18-tem, both are kept; only versions that are neither referenced nor the default are candidates for removal

Note: this is intentionally separate from sdk flush, which handles temporary files and caches under $SDKMAN_DIR/tmp and $SDKMAN_DIR/var. sdk clean operates on installed candidate versions only.

Originally requested in sdkman/sdkman-cli#688.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions