Summary
Walk up the directory tree when looking for .sdkmanrc, similar to how Git discovers .git.
Currently, sdk env (and auto-env on cd) only checks for .sdkmanrc in the exact current directory. If you cd into a subdirectory of a project — e.g. a module of a multi-module build — SDKMAN! silently ignores the .sdkmanrc at the project root.
Reported in sdkman/sdkman-cli#1469.
Proposed behaviour
When resolving .sdkmanrc, walk up from $PWD toward / and use the first .sdkmanrc found. Stop at the home directory or filesystem root (whichever comes first).
/home/user/projects/myapp/.sdkmanrc ← found here
/home/user/projects/myapp/module/ ← cd into this
Result: the .sdkmanrc from myapp/ is applied, just as if the user were in the project root.
Semantics
- Discovery order:
$PWD → parent → grandparent → … → $HOME (stop; do not cross home boundary)
- Auto-env on
cd: same walk-up logic — fires whenever the resolved .sdkmanrc path changes
- Explicit
sdk env: same walk-up logic
- No
.sdkmanrc found anywhere in the tree: existing behaviour (no-op)
Motivation
Multi-module projects (Gradle, Maven) share a single .sdkmanrc at the repo root. Developers naturally cd into submodules while working. The current behaviour forces them to either duplicate .sdkmanrc in every subdirectory or always stay at the root — neither is acceptable.
The Git precedent (git works from any subdirectory by walking up to .git) sets a clear user expectation.
Summary
Walk up the directory tree when looking for
.sdkmanrc, similar to how Git discovers.git.Currently,
sdk env(and auto-env oncd) only checks for.sdkmanrcin the exact current directory. If youcdinto a subdirectory of a project — e.g. a module of a multi-module build — SDKMAN! silently ignores the.sdkmanrcat the project root.Reported in sdkman/sdkman-cli#1469.
Proposed behaviour
When resolving
.sdkmanrc, walk up from$PWDtoward/and use the first.sdkmanrcfound. Stop at the home directory or filesystem root (whichever comes first).Result: the
.sdkmanrcfrommyapp/is applied, just as if the user were in the project root.Semantics
$PWD→ parent → grandparent → … →$HOME(stop; do not cross home boundary)cd: same walk-up logic — fires whenever the resolved.sdkmanrcpath changessdk env: same walk-up logic.sdkmanrcfound anywhere in the tree: existing behaviour (no-op)Motivation
Multi-module projects (Gradle, Maven) share a single
.sdkmanrcat the repo root. Developers naturallycdinto submodules while working. The current behaviour forces them to either duplicate.sdkmanrcin every subdirectory or always stay at the root — neither is acceptable.The Git precedent (
gitworks from any subdirectory by walking up to.git) sets a clear user expectation.