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.
Feature request
Implement a
sdk cleansubcommand that removes installed SDK versions no longer referenced by any.sdkmanrcfile — i.e., orphaned versions that have accumulated over time.This is analogous to
brew autoremovefor SDKMAN! candidates: it identifies versions that are installed but not pinned by any project configuration, and removes them to recover disk space.Proposed behaviour
.sdkmanrcfiles found under a configurable base directory (e.g.~/).sdkmanrc--dry-runflag to list what would be removed without actingdefaultversion of each candidate, even if it is not referenced by any.sdkmanrcfile — so if.sdkmanrcpinsjava=21.0.10-temand the default is17.0.18-tem, both are kept; only versions that are neither referenced nor the default are candidates for removalNote: this is intentionally separate from
sdk flush, which handles temporary files and caches under$SDKMAN_DIR/tmpand$SDKMAN_DIR/var.sdk cleanoperates on installed candidate versions only.Originally requested in sdkman/sdkman-cli#688.