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

ide create installs wrong Java version #588

Closed
hohwille opened this issue Sep 5, 2024 · 3 comments · Fixed by #642
Closed

ide create installs wrong Java version #588

hohwille opened this issue Sep 5, 2024 · 3 comments · Fixed by #642
Assignees
Labels
bug Something isn't working create Create commandlet used to create new IDEasy projects with "ide create" settings ide-settings repo and replated processes and features

Comments

@hohwille
Copy link
Member

hohwille commented Sep 5, 2024

Expected behavior

As a IDEasy user, I want to setup a project with create command and get a consistent result so that I can rely on IDEasy.

Actual behavior

I get a wrong Java version installed:

Successfully installed java in version 22.0.2_9

However, if I look at settings/ide.properties to see what has been configured, I find this:

JAVA_VERSION=21*

Steps to reproduce (bug) / Use Case of feature request (enhancement)

  1. ide create demoproject -

Related/Dependent Issues

May be related to #131
However, with Java versions we already had strange effects because of this underscore semantics.
See also #235

Comments/Hints:

If I later go the the project and call ide update, then it installs 21.0.4_7:

Successfully installed java in version 21.0.4_7 replacing previous version 22.0.2_9

This does not make sense.

Affected version:

  • OS: error reproduced both on Windows and Ubuntu Linux
  • IDEasy: 2024.09.001-beta-SNAPSHOT
@hohwille hohwille added the bug Something isn't working label Sep 5, 2024
@github-project-automation github-project-automation bot moved this to 🆕 New in IDEasy board Sep 5, 2024
@hohwille hohwille added this to the release:2024.09.002 milestone Sep 5, 2024
@hohwille
Copy link
Member Author

This bug is not specific for JAVA_VERSION.
There is a severe design flaw in how we implemented CreateCommandlet:
It creates the IdeContext to run the command from the current project or with no custom variables if we are not inside an IDE project.
After cloning the settings, we need to create a new IdeContext or more likely update the existing IdeContext with the new cloned settings and new IDE_HOME location.
This is currently not happening. As a result, I am installing the new project with the settings of the previous project where I did run the ide create command.
This can have severe implications and cause effects that even wont repair themselves if I later run ide update on that newly created project.

@hohwille hohwille self-assigned this Sep 20, 2024
@hohwille
Copy link
Member Author

OK, I debugged the creation process and I was wrong with my previous comment:
The code (setIdeHome) properly re-initializes the IdeContext but the problem is that it does that before cloning the settings. As a result there are no settings and the variables are empty. Hence no JAVA_VERSION or other such variables are defined and as a result we always get the latest version and not the versions configured in the settings.
The reason that java gets installed with no variable defined comes from here:

VariableDefinitionStringList IDE_TOOLS = new VariableDefinitionStringList("IDE_TOOLS", "DEVON_IDE_TOOLS", c -> List.of("mvn", "npm"));

So we install mvn by default that has a dependency to java.
As a result, we just need to first clone the settings and initialize the config folder and then re-initialize the IdeContext.

@hohwille
Copy link
Member Author

The only disadvantage I can see with the current solution is that we create and load the EnvironmentVariables three times:

  1. for the project where ide create is invoked
  2. on the new project before it is populated with settings
  3. on the new project after it is populated

We cannot easily omit 1. and we surely want 3. what is the actual fix of this issue.
Omitting 2. would save some millis and directory operations but IMHO we should go for KISS and consistency.

@github-project-automation github-project-automation bot moved this from 🆕 New to ✅ Done in IDEasy board Sep 20, 2024
@hohwille hohwille added settings ide-settings repo and replated processes and features create Create commandlet used to create new IDEasy projects with "ide create" labels Sep 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working create Create commandlet used to create new IDEasy projects with "ide create" settings ide-settings repo and replated processes and features
Projects
Status: ✅ Done
Development

Successfully merging a pull request may close this issue.

1 participant