Skip to content

LSP4IJ's bundling of Google Gson is causing runtime linkage errors in other plugins due to a version conflict on that library #988

Closed

Description

@SCWells72

You can find the details here, but the bottom line is that with LSP4IJ installed and enabled in 2025.1, the IDE's internal TypeScript compiler fails with a LinkageError due to multiple conflicting versions of Google Gson being present and loaded in different class loaders.

This can affect both LSP4IJ itself and any third-party plugin that has an expressed dependency on the LSP4IJ plugin because then LSP4IJ's bundled library jars become part of the dependent plugin's classpath.

Why is LSP4IJ bundling its own version of Google Gson when the IDE is already guaranteed to have that available in the classpath? It might be worth seeing whether or not it's safe to remove that bundling -- and any other bundlling of third-party jars that are already available via the IDE itself -- to avoid such conflicts.

Activity

  1. angelozerr commented on Apr 22, 2025

    @angelozerr
    Contributor

    You can find the details here, but the bottom line is that with LSP4IJ installed and enabled in 2025.1, the IDE's internal TypeScript compiler fails with a LinkageError due to multiple conflicting versions of Google Gson being present and loaded in different class loaders.

    This can affect both LSP4IJ itself and any third-party plugin that has an expressed dependency on the LSP4IJ plugin because then LSP4IJ's bundled library jars become part of the dependent plugin's classpath.

    Why is LSP4IJ bundling its own version of Google Gson when the IDE is already guaranteed to have that available in the classpath? It might be worth seeing whether or not it's safe to remove that bundling -- and any other bundlling of third-party jars that are already available via the IDE itself -- to avoid such conflicts.

    It is because LSP4J (not LSP4IJ) depends on GSon. We could try to exclude it.

    I am super busy with LSP4IJ release, if you have time to explore this exclusion of Gson, it will help me a lot.

  2. SCWells72 commented on Apr 22, 2025

    @SCWells72
    ContributorAuthor

    It is because LSP4J (not LSP4IJ) depends on GSon. We could try to exclude it.

    I am super busy with LSP4IJ release, if you have time to explore this exclusion of Gson, it will help me a lot.

    Unfortunately with my upcoming move, I won't have spare time for anything but my day job and move preparation for the next few months. Just be aware that if any third-party plugin that uses LSP4IJ in 2025.1 calls a plugin SDK that in turns uses Google Gson -- in my case it was the in-process TypeScript compiler -- it's likely going to fail with a LinkageError at runtime.

  3. InSyncWithFoo commented on Apr 22, 2025

    @InSyncWithFoo
    Contributor

    See also #459.

  4. angelozerr commented on Apr 22, 2025

    @angelozerr
    Contributor

    This issue is super urgent.

    @sbouchet is there any chance that you help me,?

    if we don't fix this issue, I am pretty sure that LSP4IJ will be give up.

  5. SCWells72 commented on Apr 22, 2025

    @SCWells72
    ContributorAuthor

    To be clear, I think that there are two aspects of this.

    The first is to try to either remove the bundled Google Gson jar or, if that's impossible, try to align it with the version bundled with the IDE. The latter will be difficult because IDE versions before 2025.1 used one version and 2025.1 uses another, so bundling a version with LSP4IJ that doesn't produce conflicts with some subset of host IDE versions may be challenging at best and likely even impossible. Ideally LSP4IJ would just stop bundling Gson and would use the one included with the host IDE. JetBrains IDEs have bundled Gson for at least a decade, so unless LSP4J is using some very version-specific Gson API, it should just work with the IDE's bundled one.

    The second is the analogous issue discussed in #459 where recent commercial JetBrains IDEs also bundle their own version of LSP4IJ, and, starting with PyCharm, JetBrains is also trying to unify commercial IDEs with Community Edition IDEs via licensing instead of distinct distributions, so those jars are already starting to be present in Community Edition IDEs as well. I've not personally seen any LSP4J conflicts in commercial IDEs, but I also primarily focus on LSP4IJ in Community Edition IDEs to provide support for languages like JavaScript, TypeScript, and CSS in those IDEs which do not include first-class support for them.

    For the latter, it seems like there are two options:

    1. LSP4IJ would bundle jars from the exact same version of LSP4J that's bundled with the IDE, and those jars would be extraneous when installed into a commercial IDE that already includes them but required when installed into a Community Edition IDE that does not.
    2. LSP4IJ would have two distributions, one for IDEs that bundle LSP4J and one for IDEs that do not. The former would not bundle its own LSP4J jars at all and just depend on the IDE's. The latter would be like today where LSP4J is bundled with the plugin since it's not present in the host IDE.

    Neither approach is perfect, but to be honest, the second is probably the most robust because it ensures that there is no chance of a version conflict between the host IDE and the plugin. However, it's also the more complex because it requires two build outputs targeting distinct and disjoint subsets of supported IDEs.

    Oh, and it's worth noting that the IDE's bundled LSP4IJ classes seem to be in lib.jar:

    Image

    Apologies for the total brain dump. I wish I could help a bit more here, but as I alluded above, my family is currently in the middle of a pretty huge change -- moving cross-country -- and my focus will need to be on that and my day job until things have settled in a few months.

  6. angelozerr commented on Apr 22, 2025

    @angelozerr
    Contributor

    According @SCWells72:

    Here's what they're using in 2025.1:
    org.eclipse.lsp4j.debug:0.14.0 0.21.0
    org.eclipse.lsp4j.jsonrpc.debug:0.14.0 0.21.0
    org.eclipse.lsp4j.jsonrpc:0.14.0 0.21.1
    org.eclipse.lsp4j:0.14.0 0.21.1
    
    I got that using Help | About and clicking the "open-source software" link in the resulting dialog.
    

    In your case we use 0.21.1. I don't know what 0.14.0 means?

  7. angelozerr commented on Apr 23, 2025

    @angelozerr
    Contributor

    @SCWells72 I have started something with #989

  8. sbouchet commented on Apr 23, 2025

    @sbouchet
    Contributor

    @angelozerr looksgood to me, tested successfully on 2025.1 with intellij-quarkus

  9. added
    bug
    on Apr 24, 2025
  10. added this to the 0.13.0 milestone on Apr 24, 2025
  11. angelozerr commented on Apr 24, 2025

    @angelozerr
    Contributor

    Fixed with #989

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions