sourcegraph / scip-java

SCIP Code Intelligence Protocol generator for Java
https://sourcegraph.github.io/scip-java/
Apache License 2.0
69 stars 28 forks source link

`NoSuchMethodError` in 0.8.4 #486

Closed ckipp01 closed 2 years ago

ckipp01 commented 2 years ago

The issue

When attempting to update https://github.com/ckipp01/mill-scip to 0.8.4 for a minimal hello-world integration test for Scala I'm seeing the following:

_Taken from the CI logs_

Staring to create a scip index from 3 SemanticDB documents.
[1/2] io.kipp.mill.scip.Scip.generate | [0/3] processing semanticdb
1 targets failed
io.kipp.mill.scip.Scip.generate java.lang.NoSuchMethodError: com.google.protobuf.GeneratedMessageV3.isStringEmpty(Ljava/lang/Object;)Z
    com.sourcegraph.Scip$ToolInfo.getSerializedSize(Scip.java:4680)
    com.google.protobuf.CodedOutputStream.computeMessageSizeNoTag(CodedOutputStream.java:877)
    com.google.protobuf.CodedOutputStream.computeMessageSize(CodedOutputStream.java:661)
    com.sourcegraph.Scip$Metadata.getSerializedSize(Scip.java:3524)
    com.google.protobuf.CodedOutputStream.computeMessageSizeNoTag(CodedOutputStream.java:877)
    com.google.protobuf.CodedOutputStream.computeMessageSize(CodedOutputStream.java:661)
    com.sourcegraph.Scip$Index.getSerializedSize(Scip.java:1826)
    com.google.protobuf.AbstractMessageLite.toByteArray(AbstractMessageLite.java:69)
    com.sourcegraph.scip_semanticdb.ScipWriter.emitTyped(ScipWriter.java:47)
    com.sourcegraph.scip_semanticdb.ScipSemanticdb.runTyped(ScipSemanticdb.java:66)
    com.sourcegraph.scip_semanticdb.ScipSemanticdb.run(ScipSemanticdb.java:57)
    com.sourcegraph.scip_semanticdb.ScipSemanticdb.run(ScipSemanticdb.java:37)
    io.kipp.mill.scip.Scip$.createScip(Scip.scala:276)
    io.kipp.mill.scip.Scip$.$anonfun$generate$2(Scip.scala:208)

The same semanticdb documents can be processed with scip-java index-semanticdb, but not when doing it via ScipSemanticdb.run(options). You can see how I put this together here:

https://sourcegraph.com/github.com/ckipp01/mill-scip/-/blob/plugin/src/io/kipp/mill/scip/Scip.scala?L231-276

At first glance I can't really see what change is causing this, but maybe I'm doing something wrong with putting together my LsifToolInfo, ScipSemanticdbOptions, etc. I'll dig in more, but just wanted to report this right away.

Expectation

I'd expect ScipSemantcdb.run(options) to work the same as it did in 0.8.2 since this was just a patch release.

ckipp01 commented 2 years ago

Digging in a bit more, @olafurpg do you have any more context to the protobuf bump in https://github.com/sourcegraph/scip-java/commit/62c2f8d9af2cc79da57df097758a7d7df20943ce? I see the error I'm hitting on has been reported before https://github.com/protocolbuffers/protobuf/issues/9236 and it sort of seems like based on some of the comments in there:

This is caused by a mismatch between the protoc compiler version and the runtime version.

I do see that we are at 3.21.4, but we also have some other versions coming in from things like:

❯ cs resolve com.thesamet.scalapb:compilerplugin_2.12:0.10.10
com.google.protobuf:protobuf-java:3.12.2:default
com.thesamet.scalapb:compilerplugin_2.12:0.10.10:default
com.thesamet.scalapb:protoc-bridge_2.12:0.9.0:default
com.thesamet.scalapb:protoc-gen_2.12:0.9.0:default
dev.dirs:directories:23:default
org.scala-lang:scala-library:2.12.13:default
org.scala-lang.modules:scala-collection-compat_2.12:2.3.2:default

But I'm unsure if that's just a red herring. I also double-checked in mill-scip to make sure I didn't have some other random version floating around and evicting, but that doesn't seem to be the case.

olafurpg commented 2 years ago

Thank you for reporting! I bumped up protobuf to make the local build work on my new M1 MBP, but this version is otherwise not needed for runtime functionality. I opened #488 which should fix the issue.

olafurpg commented 2 years ago

I cut a new 0.8.5 release with the protobuf downgrade to see if that fixes the issue for you.

ckipp01 commented 2 years ago

Just confirming that 0.8.5 does indeed fix it for me. Thanks!