sdkman / sdkman-cli

The SDKMAN! Command Line Interface
https://sdkman.io
Apache License 2.0
5.97k stars 629 forks source link

Bug: sdk home asks interactively for an upgrade and shows the hint to run sdk update #1196

Closed mh182 closed 1 year ago

mh182 commented 1 year ago

Bug report Calling sdk home checks for sdk upgrade and asks interactively for an upgrade even if called within a script.

To reproduce

Echo home directory of installed docToolchain version

Returns 0 if installed, otherwise 1

sdk_home_doctoolchain() { local version=${1}

source "${SDKMAN_DIR}/bin/sdkman-init.sh"
sdk home doctoolchain "${version}" 2>/dev/null

}

echo "Location of docToolchain: $(sdk_home_doctoolchain 2.2.1)"

* Wait a couple of days/weeks until a new SDKMAN! version is available.
* If a new version of sdkman is available the script blocks due to the interactive question if I would like to upgrade to the nevwer version.
* The output contains information to run `sdk update` which makes the command unusable to scripting purpose

➜ sdk home doctoolchain 2.2.1 2>/dev/null

We periodically need to update the local cache. Please run:

$ sdk update

/home/max/.local/share/sdkman/candidates/doctoolchain/2.2.1


**What would I have expected**

I would not have expected that the `home` command checks for an upgrade and asks me interactively to do it. I would understand it if I would like to use `install` or `list`, but to retrieve the path of an installed application?

The default setting of `sdkman` regarding the auto-upgrade makes it error-prone and is surprising to existing command line tools.

Default settings are

sdkman_auto_answer=false sdkman_auto_update=true


`sdk` changes its behavior based on external impacts. Even worse, if called once, it suddenly changes the behavior and I have to wait another day (?) until I can reproduce this error again.

Why does a command, which purpose is to provide an output of an already installed application, change its output based on external factors (like time or new release)?

**System info**
- OS: Linux, Debian 12.0

➜ bash --version GNU bash, Version 5.2.15(1)-release (x86_64-pc-linux-gnu)

➜ sdk version We periodically need to update the local cache. Please run:

$ sdk update

SDKMAN! script: 5.18.0 native: 0.1.3

marc0der commented 1 year ago

This functionality will be removed shortly, along with all other reminders. The self update nagging and broadcast messages have already been removed and all this is already available on our beta channel.

marc0der commented 1 year ago

@mh182 Right, I've taken a deeper dive into this. There is no interactive upgrade notification (this was removed as part of the 5.18.0 release), but just an update notification (asking you to refresh the candidate cache).

I've opened a new PR #1197 that removes this nag and no longer checks to see if your candidate cache is out of date. It means that if a new candidate is added to SDKMAN, you would need to run sdk update explicitly to discover and start using it. These details are clearly laid out in sdk help update.

mh182 commented 1 year ago

Sorry, I meant "update" and not "upgrade". Thanks for the change.