Skip to content

feat: walk up directory tree to discover .sdkmanrc #398

@chloe41427

Description

@chloe41427

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions