devonfw / IDEasy

Tool to automate the setup and updates of a development environment for any project (Successor of devonfw-ide).
Apache License 2.0
7 stars 18 forks source link

Inconsistent behavior of get-version and get-edition #410

Closed slskiba closed 1 week ago

slskiba commented 1 week ago

Actual behavior

Inconsistent behaviour: get-edition of a local tool that is not installed provides the configured edition and instructions on how to install the tool, however get-version of a local tool that is not installed results in a CliException: Tool <tool> is not installed get-version of a global tool fails in CliException: Tool <tool> is not installed: Tool not installed, whether it is installed or not.

Related Issues

Comments/Hints:

The current implementation for get-version and get-edition is only applicable to local tools.

hohwille commented 1 week ago

I get different results:

$ ide -v
2024.06.001-alpha-SNAPSHOT
Successfully completed ide (-v)
$ ide get-version aws
2.15.58
Successfully completed ide (get-version,aws)
$ ide get-edition aws
aws
Successfully completed ide (get-edition,aws)

Can you specify how to reproduce the CliException: Tool is not installed case?

hohwille commented 1 week ago

However, some things are inconsistent:

$ ide get-edition docker
The configured edition for tool docker is rancher
To install that edition call the following command:
ide install docker
Successfully completed ide (get-edition,docker)

I also was now able to reproduce the reported error:

$ ide get-version helm
Step 'ide (get-version,helm)' failed: com.devonfw.tools.ide.cli.CliException: Tool helm is not installed!
1 step(s) failed out of 1 steps.
Tool helm is not installed!

Error: IDEasy failed with exit code 4
slskiba commented 1 week ago

Seems like aws is installed in your case. The exception of course occurs when a tool is not installed. However get-edition does not throw this exception when a tool is not installed - I suggest they should behave similar when called on a tool that is not installed.

hohwille commented 1 week ago

FYI: My expectation is that get-version only prints the version and get-edition only prints the edition. We can also log the verbose message texts around this but on debug level. So I would expect this:

$ ide get-edition docker
rancher
$ ide -d get-edition docker
The configured edition for tool docker is:
rancher
To install that edition you can call the following command:
ide install docker

UPDATE: OK. Now I got the difference. If the tool is installed, I get the installed edition and version (I wounder how I could actually determine the installed edition. IMHO there is currently no way to do this). However for get-version I could get something like 21* for Java if the tool is not installed. I could still print the resolved version that would be installed if I do install it now...

slskiba commented 1 week ago

$ ide get-edition docker rancher

I am unable to reproduce this result. I am experiencing the following for docker (with rancher installed), and aws (not installed):

ide> get-edition docker
The configured edition for tool docker is rancher
To install that edition call the following command:
ide install docker
Successfully completed ide (get-edition,docker)

ide> get-version docker
Step 'ide (get-version,docker)' failed: com.devonfw.tools.ide.cli.CliException: Tool docker is not installed!
1 step(s) failed out of 1 steps.
[..]

ide> get-edition aws
The configured edition for tool aws is aws
To install that edition call the following command:
ide install aws
Successfully completed ide (get-edition,aws)

ide> get-version aws
Step 'ide (get-version,aws)' failed: com.devonfw.tools.ide.cli.CliException: Tool aws is not installed!
1 step(s) failed out of 1 steps.
[..]

However I would expect:

ide> get-edition docker
The configured edition for tool docker is rancher
To install that edition call the following command:
ide install docker

ide> get-version docker
The configured version for tool docker is *
To install that version call the following command:
ide install docker

ide> get-edition aws
The configured edition for tool aws is aws
To install that edition call the following command:
ide install aws

ide> get-version aws
The configured version for tool aws is 2*
To install that version call the following command:
ide install aws

While there might be more appropriate output for docker, the current implementation of get-version and get-edition are based on finding the tool in the software path, which simply isn't applicable for global tools.