microsoft / vscode-java-dependency

Manage Java projects in Visual Studio Code.
https://marketplace.visualstudio.com/items?itemName=vscjava.vscode-java-dependency
MIT License
152 stars 74 forks source link

'java.configuration.runtimes' seems to be shared accross different projects in different devcontainers when they run concurrently (and I think they should be independent). #759

Closed tchinchow closed 1 year ago

tchinchow commented 1 year ago

The bug / what is happening:

When I try to open 2 different projects:

then I'd expect that "java.configuration.runtimes" to be different in both dev containers and match the java version installed in the corresponding container.

However, something strange and rather buggy happens instead:

When I get one container working, I get the following error in the OTHER container:

image

In the above message the JDK path is that of the first container and

I simply don't know what it is doing there and cannot find any reference to it in the second project.

I can have one or the other container working by cleaning the java server workspace but never both at once.

Even stranger:

When I choose "Open Settings" on that notification / pop-up dialog, then

  1. Select "Remote (dev container)" tab
  2. click "Edit in settings.json"
  3. vscode magically opens a settings.json file
  4. I confirm that the settings are indeed not following those specified in the devcontainer.json of the current container !
  5. I Modify the settings.json that was automagically opened and MAKE it match the expected value for its devcontainer specification
  6. Then I get the error message on the other running container !!! It really seems like the other container take the modification for itself as well and now complains that its java runtime does not exist (but it was working before the modification made in the other container !)

Conclusion: They seem to share the setting but I do not understand why ? and I believe that the should not !

Misc information

Steps to Reproduce:

  1. Create 2 projects using devcontainers and using with different JDKs:

    It is important to note that both devcontainers use

    • different base containers, AND
    • different devcontainer.json with
    • different java.configuration.runtimes settings

    dev environment #1:

    {
       ...
       "name": "dev container #1",
       "build": {
           ...
           "target": "my-builder-java8-oracle"
       },
       ...
       "customizations": {
           "vscode": {
               "settings": {
                   "java.jdt.ls.java.home": "/usr/lib/jvm/java-17-openjdk-17.0.6.0.10-3.el8_7.x86_64",
                   // "java.configuration.maven.globalSettings": "/fit-src/settings.xml",
                   "java.configuration.maven.userSettings": "/fit-src/settings.xml",
                   "java.configuration.runtimes": [
                       {
                         "name": "JavaSE-1.8",
                         "path": "/usr/java/jdk1.8.0_351-amd64",
                         "default": true
                       }, {
                         "name": "JavaSE-17",
                         "path": "/usr/lib/jvm/java-17-openjdk-17.0.6.0.10-3.el8_7.x86_64"
                       }
                   ],
                   // Setting `maven.executable.options` would help with Microsoft "vscode-maven" extension but not with the CLI.
                   // see "postCreateCommand" section below.
                   // "maven.executable.options": "-o -s /fit-src/settings.xml -Dmaven.repo.local=/fit-src/maven-repo",
                   "maven.settingsFile": "/my-project/settings.xml",
                   "redhat.telemetry.enabled": false
               },
               "extensions": [
                   "ms-azuretools.vscode-docker",
                   "redhat.java",
                   "VisualStudioExptTeam.intellicode-api-usage-examples",
                   "VisualStudioExptTeam.vscodeintellicode",
                   "vscjava.vscode-java-debug",
                   "vscjava.vscode-java-dependency",
                   "vscjava.vscode-java-pack",
                   "vscjava.vscode-java-test",
                   "vscjava.vscode-maven"
               ]
           }
       }
    }

    and dev environment #1:

    {
       NOTE: same as above just modify the jre 1.8 path to match that of the container
       ...
       "name": "dev container #2",
       "build": {
           ...
           "target": "my-builder-java8-openjdk"
       },
       ...
       "customizations": {
           "vscode": {
               "settings": {
                   "java.jdt.ls.java.home": "/usr/lib/jvm/java-17-openjdk-17.0.6.0.10-3.el8_7.x86_64",
                   // "java.configuration.maven.globalSettings": "/fit-src/settings.xml",
                   "java.configuration.maven.userSettings": "/fit-src/settings.xml",
                   "java.configuration.runtimes": [
                       {
                         "name": "JavaSE-1.8",
                         "path": "/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.362.b09-2.el8_7.x86_64",
                         "default": true
                       }, {
                         "name": "JavaSE-17",
                         "path": "/usr/lib/jvm/java-17-openjdk-17.0.6.0.10-3.el8_7.x86_64"
                       }
                   ],
                   // Setting `maven.executable.options` would help with Microsoft "vscode-maven" extension but not with the CLI.
                   // see "postCreateCommand" section below.
                   // "maven.executable.options": "-o -s /fit-src/settings.xml -Dmaven.repo.local=/fit-src/maven-repo",
                   "maven.settingsFile": "/my-project/settings.xml",
                   "redhat.telemetry.enabled": false
               },
               "extensions": [
                   "ms-azuretools.vscode-docker",
                   "redhat.java",
                   "VisualStudioExptTeam.intellicode-api-usage-examples",
                   "VisualStudioExptTeam.vscodeintellicode",
                   "vscjava.vscode-java-debug",
                   "vscjava.vscode-java-dependency",
                   "vscjava.vscode-java-pack",
                   "vscjava.vscode-java-test",
                   "vscjava.vscode-maven"
               ]
           }
       }
    }

I'm not sure of what extension is causing this... Who is using the "java.configuration.runtimes" settings ?

jdneo commented 1 year ago

This setting is consumed by the extension redhat.java.

I'll try to repro it when I have time. At the meantime, could you please check if you have defined java.configuration.runtimes in somewhere else? This setting's scope is machine-overidable, according to VS Code document, it can be overridden by workspace or folder settings.

tchinchow commented 1 year ago

Thanx @jdneo for your time and help.

According to what I see in the vscode settings dialog (inside the container), the java.configuration.runtimes setting is

I have created the issue report / call for help ;) in redhat.java

Many many thanx again. vscode is a great tool !

tchinchow commented 1 year ago

I'll close the issue since I opened another ticket elsewhere.