Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Restoring default env breaks when .sdkmanrc is gone on folder exit #1241

Open
Philzen opened this issue Sep 26, 2023 · 2 comments
Open
Labels

Comments

@Philzen
Copy link

Philzen commented Sep 26, 2023

Bug report
When i cd into a directory with an .sdkmanrc, it fails to restore the defaults when leaving the directory again when the .sdkmanrc file doesn't exist anymore by then (for instance b/c i switched to a git branch where it didn't exist yet).

To reproduce

I'm using sdkman with sdkman_auto_env=true

  1. cd ~/cool-project where cool-project folder currently contains an .sdkmanrc (→ sdkman loads correct i.e. maven & java version)
  2. delete .sdkmanrc
  3. cd..
    → 💥 Could not find /home/user/cool-project/.sdkmanrc.

Now checking sdk current reveals that the default versions have not been restored – the shell still uses the versions that SDKMAN! loaded after entering the cool-project directory.

System info

→ Linux mymachine-user 6.1.53-1-MANJARO #1 SMP PREEMPT_DYNAMIC Wed Sep 13 14:10:57 UTC 2023 x86_64 GNU/Linux
→ GNU bash, version 5.1.16(1)-release (x86_64-pc-linux-gnu)
→ SDKMAN!  
    script: 5.18.2
    native: 0.4.2
@Philzen Philzen added the bug label Sep 26, 2023
@Philzen
Copy link
Author

Philzen commented Sep 26, 2023

BTW it would be really nice in this situation to be able to easily load the defaults, maybe using something such as sdk use defaults.

@Philzen Philzen changed the title Bug: Restoring default env breaks when .sdkenvrc is gone on folder exit Bug: Restoring default env breaks when .sdkmanrc is gone on folder exit Sep 26, 2023
@helpermethod
Copy link
Member

Hi @Philzen

The clear mechanism currently

  • stores the location of the .sdkmanrc file
  • use the candidates in the file to reset them to their defaults

I wonder if the whole restoring defaults mechanism wouldn't be fixed by introducing a global .sdkmanrc file in the $HOME directory, like other tools do.

The env command could then walk up the directory tree until it hits "$HOME" and look in each parent directory for an .sdkmanrc file.

AFAIK other tools like nvm etc. also do it that way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants