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

undeclared and unused contradiction #46

Open
steinybot opened this issue Nov 28, 2019 · 8 comments
Open

undeclared and unused contradiction #46

steinybot opened this issue Nov 28, 2019 · 8 comments

Comments

@steinybot
Copy link

I have setup the Akka gRPC Hellow World server and the first thing I get is:

sbt:bug-reports> undeclaredCompileDependenciesTest
...
[warn] bug-reports >>> The project depends on the following libraries for compilation but they are not declared in libraryDependencies:
[warn]  - "com.google.protobuf" % "protobuf-java" % "3.8.0"
[warn]  - "com.lightbend.akka.grpc" %% "akka-grpc-runtime" % "0.7.2"
[warn]  - "com.thesamet.scalapb" %% "lenses" % "0.9.1"
[warn]  - "com.typesafe" % "config" % "1.3.4"
[warn]  - "com.typesafe.akka" %% "akka-actor" % "2.5.25"
[warn]  - "com.typesafe.akka" %% "akka-http-core" % "10.1.10"
[warn]  - "com.typesafe.akka" %% "akka-stream" % "2.5.25"
[warn]  - "io.grpc" % "grpc-api" % "1.24.0"
[error] (undeclaredCompileDependenciesTest) Failing the build because undeclared dependencies were found
[error] Total time: 2 s, completed 29/11/2019 11:14:35 AM

Now when I add those dependencies:

sbt:bug-reports> undeclaredCompileDependenciesTest
[warn] There may be incompatibilities among your library dependencies; run 'evicted' to see detailed eviction warnings.
[info] bug-reports >>> The project explicitly declares all the libraries that it directly depends on for compilation. Good job!
[success] Total time: 1 s, completed 29/11/2019 11:15:43 AM

So far so good... but:

sbt:bug-reports> unusedCompileDependenciesTest
[warn] bug-reports >>> The following libraries are declared in libraryDependencies but are not needed for compilation:
[warn]  - "com.lightbend.akka.grpc" % "akka-grpc-runtime_2.13" % "0.7.2"
[warn]  - "io.grpc" % "grpc-stub" % "1.24.0"
[error] (unusedCompileDependenciesTest) Failing the build because unused dependencies were found
[error] Total time: 0 s, completed 29/11/2019 11:16:23 AM

This contradicts the first result.

See https://github.com/steinybot/bug-reports/tree/sbt-explicit-dependencies/contradiction for a project which reproduces this problem.

@cb372
Copy link
Owner

cb372 commented Dec 1, 2019

Thanks for the clear bug report. I agree this looks odd. I haven’t had a chance to look into it yet.

@steinybot
Copy link
Author

It is just the "com.lightbend.akka.grpc" % "akka-grpc-runtime_2.13" % "0.7.2" dependency which is acting up. It might have something to do with the fact that it is only used by managed sources. So it seems the unused check is the one that is incorrect.

The other gRPC one should have been scoped to the Runtime configuration. The error message for this case could be a bit better.

@steinybot
Copy link
Author

Hmm I swear marking "io.grpc" % "grpc-stub" % "1.24.0" as Runtime fixed the warning. Now it seems to be back again. Everything still compiles fine with it set to Runtime so that ought to be the solution.

@alexklibisz
Copy link

@steinybot Did you ever figure this out? I'm stuck on the same thing now, also using the akka-grpc and scalapb libraries.

@steinybot
Copy link
Author

@alexklibisz No I don't think that I did.

@anilkumarmyla
Copy link
Contributor

If its of any help, you can try setting the loglevel to debug to understand the inner workings (recently added) of this plugin as described here https://github.com/cb372/sbt-explicit-dependencies#debugging

@anilkumarmyla
Copy link
Contributor

Updating the plugin to 0.2.13 and running on your reproduction repo we get this for

sbt -debug undeclaredCompileDependenciesTest

[debug] Compile depends on:
[debug]   "com.thesamet.scalapb" %% "scalapb-runtime" % "0.9.1"
[debug]   "com.google.protobuf" % "protobuf-java" % "3.8.0"
[debug]   "com.typesafe.akka" %% "akka-actor" % "2.5.25"
[debug]   "com.lightbend.akka.grpc" %% "akka-grpc-runtime" % "0.7.2"
[debug]   "com.typesafe.akka" %% "akka-stream" % "2.5.25"
[debug]   "io.grpc" % "grpc-api" % "1.24.0"
[debug]   "com.thesamet.scalapb" %% "lenses" % "0.9.1"
[debug]   "com.typesafe" % "config" % "1.3.4"
[debug]   "com.typesafe.akka" %% "akka-http-core" % "10.1.10"
[debug] Declared dependencies:
[debug]   "com.thesamet.scalapb" %% "scalapb-runtime" % "0.9.1"
[debug]   "com.lightbend.akka.grpc" % "akka-grpc-runtime_2.13" % "0.7.2"
[debug]   "io.grpc" % "grpc-stub" % "1.24.0"
[debug]   "com.lightbend.akka.grpc" % "akka-grpc-runtime_2.13" % "0.7.2"
[debug]   "com.lightbend.akka.grpc" % "akka-grpc-runtime_2.13" % "0.7.2"
[debug]   "com.google.protobuf" % "protobuf-java" % "3.8.0"
[debug]   "com.lightbend.akka.grpc" %% "akka-grpc-runtime" % "0.7.2"
[debug]   "com.thesamet.scalapb" %% "lenses" % "0.9.1"
[debug]   "com.typesafe" % "config" % "1.3.4"
[debug]   "com.typesafe.akka" %% "akka-actor" % "2.5.25"
[debug]   "com.typesafe.akka" %% "akka-http-core" % "10.1.10"
[debug]   "com.typesafe.akka" %% "akka-stream" % "2.5.25"
[debug]   "io.grpc" % "grpc-api" % "1.24.0"
[info] bug-reports >>> The project explicitly declares all the libraries that it directly depends on for compilation. Good job!

All good? Not really, if you observe carefully, our Declared dependencies have gotten a lot bigger than what we originally have in build.sbt (this maybe due to the addition of sbt plugins) and consequently following fails

sbt -debug unusedCompileDependenciesTest

[debug] Compile depends on:
[debug]   "com.thesamet.scalapb" %% "scalapb-runtime" % "0.9.1"
[debug]   "com.google.protobuf" % "protobuf-java" % "3.8.0"
[debug]   "com.typesafe.akka" %% "akka-actor" % "2.5.25"
[debug]   "com.lightbend.akka.grpc" %% "akka-grpc-runtime" % "0.7.2"
[debug]   "com.typesafe.akka" %% "akka-stream" % "2.5.25"
[debug]   "io.grpc" % "grpc-api" % "1.24.0"
[debug]   "com.thesamet.scalapb" %% "lenses" % "0.9.1"
[debug]   "com.typesafe" % "config" % "1.3.4"
[debug]   "com.typesafe.akka" %% "akka-http-core" % "10.1.10"
[debug] Declared dependencies:
[debug]   "com.thesamet.scalapb" %% "scalapb-runtime" % "0.9.1"
[debug]   "com.lightbend.akka.grpc" % "akka-grpc-runtime_2.13" % "0.7.2"
[debug]   "io.grpc" % "grpc-stub" % "1.24.0"
[debug]   "com.lightbend.akka.grpc" % "akka-grpc-runtime_2.13" % "0.7.2"
[debug]   "com.lightbend.akka.grpc" % "akka-grpc-runtime_2.13" % "0.7.2"
[debug]   "com.google.protobuf" % "protobuf-java" % "3.8.0"
[debug]   "com.lightbend.akka.grpc" %% "akka-grpc-runtime" % "0.7.2"
[debug]   "com.thesamet.scalapb" %% "lenses" % "0.9.1"
[debug]   "com.typesafe" % "config" % "1.3.4"
[debug]   "com.typesafe.akka" %% "akka-actor" % "2.5.25"
[debug]   "com.typesafe.akka" %% "akka-http-core" % "10.1.10"
[debug]   "com.typesafe.akka" %% "akka-stream" % "2.5.25"
[debug]   "io.grpc" % "grpc-api" % "1.24.0"
[warn] bug-reports >>> The following libraries are declared in libraryDependencies but are not needed for compilation:
[warn]  - "com.lightbend.akka.grpc" % "akka-grpc-runtime_2.13" % "0.7.2"
[warn]  - "io.grpc" % "grpc-stub" % "1.24.0"
[error] (unusedCompileDependenciesTest) Failing the build because unused dependencies were found

sbt-akka-grpc is explicitly adding "com.lightbend.akka.grpc" % "akka-grpc-runtime_2.13" % "0.7.2" and "io.grpc" % "grpc-stub" % "1.24.0" into the declared dependencies. First maybe easy to solve by converting the _2.13 artifact to sbt module format, but second needs to be fixed by the sbt-akka-grpc plugin.

@alexklibisz
Copy link

One sort-of solution to this is to use libraryDependencies := Seq(...) instead of ++= Seq(...). Then you have to explicitly include the scalapb-runtime, etc. versions, but it doesn't trip up the `unusedCompileDependenciesTest.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants