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

How to debug "weird" error messages #553

Closed
abergmeier opened this issue Jul 3, 2018 · 8 comments
Closed

How to debug "weird" error messages #553

abergmeier opened this issue Jul 3, 2018 · 8 comments

Comments

@abergmeier
Copy link

Due to Bazels sandboxing, it seems like I get "weird" error messages like:

Symbol 'term com.typesafe' is missing from the classpath.
This symbol is required by 'value akka.actor.ActorSystem.config'.
Make sure that term typesafe is in your classpath and check for conflicting dependencies with -Ylog-classpath.
A full rebuild may help if 'ActorSystem.class' was compiled against an incompatible version of com.
val system = ActorSystem("TestSystem")

in the input file it states:

Classpath: bazel-out/k8-fastbuild/genfiles/external/com_typesafe_akka_akka_actor/jar/_ijar/jar/external/com_typesafe_akka_akka_actor/jar/akka-actor_2.11-2.5.13-ijar.jar:bazel-out/k8-fastbuild/bin/debezium-connector-teradata/executesql_ijar.jar:bazel-out/k8-fastbuild/bin/debezium-connector-teradata/row_ijar.jar:bazel-out/k8-fastbuild/bin/debezium-connector-teradata/teradataactor_ijar.jar:bazel-out/k8-fastbuild/genfiles/external/scala/_ijar/scala-library/external/scala/lib/scala-library-ijar.jar:bazel-out/k8-fastbuild/genfiles/external/scala/_ijar/scala-reflect/external/scala/lib/scala-reflect-ijar.jar:external/scalatest/jar/scalatest_2.11-2.2.6.jar
ClasspathResourceSrcs: 
EnableIjar: False
Files: debezium-connector-teradata/TeradataActorTest.scala
IjarCmdPath: 
IjarOutput: 
JarOutput: bazel-out/k8-fastbuild/bin/debezium-connector-teradata/teradataactor_test.jar
JavaFiles: 
Manifest: bazel-out/k8-fastbuild/bin/debezium-connector-teradata/teradataactor_test_MANIFEST.MF
Plugins: 
PrintCompileTime: False
ResourceDests: 
ResourceJars: 
ResourceSrcs: 
ResourceShortPaths: 
ResourceStripPrefix: 
ScalacOpts: 
SourceJars: 
DependencyAnalyzerMode: off
StatsfileOutput: bazel-out/k8-fastbuild/bin/debezium-connector-teradata/teradataactor_test.statsfile

How should one debug that problem? I had a similar error message before and then rebuilding seem to have done the trick!?

@johnynek
Copy link
Member

johnynek commented Jul 3, 2018

These rules require you to declare all depencies you use. You don’t get transitive deps by default. It looks like you are missing some of the dependencies of akka actor.

@johnynek
Copy link
Member

johnynek commented Jul 3, 2018

The error message from scalac is pretty unhelpful. It misleads users based on the assumptions from other build tools. Maybe we should see if we can hook in and change the error message there.

If you use —java_strict_deps=error you may get a better error message.

@abergmeier
Copy link
Author

It looks like you are missing some of the dependencies of akka actor.

Thanks. That did help.

It misleads users based on the assumptions from other build tools.

It also misleads Bazel veterans ;).

@ittaiz
Copy link
Member

ittaiz commented Jul 4, 2018

@abergmeier did you try --java_strict_deps=error?

@abergmeier
Copy link
Author

abergmeier commented Mar 11, 2020

I think there is no --java_strict_deps?
Still no idea how to debug these errors in any good way :(

@ittaiz
Copy link
Member

ittaiz commented Mar 11, 2020

I actually disagree. We’ve done a lot of work on this (though it’s definitely not complete). Specifically over the past few months @Jamie5 has advanced this area greatly.
If you can take a look at the readme and specifically optionB.
We’d love to hear your feedback.

@abergmeier
Copy link
Author

abergmeier commented Mar 13, 2020

Gave option B a spin and it reduced some noise.
It also made a few things worse (I assume bugs).
For example now I get an error:

error: Target '@maven//:com_typesafe_scala_logging_scala_logging_api_2_11' is specified as a dependency to //:report but isn't used, please remove it from the deps.
You can use the following buildozer command:
buildozer 'remove deps @maven//:com_typesafe_scala_logging_scala_logging_api_2_11' //:report
src/main/scala/Foo.scala:19: error: Target 'Unknown label of file bazel-out/k8-fastbuild/bin/external/maven/v1/https/jcenter.bintray.com/org/slf4j/slf4j-api/1.7.30/stamped_slf4j-api-1.7.30.jar which came from @maven//:com_typesafe_scala_logging_scala_logging_slf4j_2_11' is used but isn't explicitly declared, please add it to the deps.
You can use the following buildozer command:
buildozer 'add deps Unknown label of file bazel-out/k8-fastbuild/bin/external/maven/v1/https/jcenter.bintray.com/org/slf4j/slf4j-api/1.7.30/stamped_slf4j-api-1.7.30.jar which came from @maven//:com_typesafe_scala_logging_scala_logging_slf4j_2_11' //:report
      logger.warn("Foo.")
                 ^
src/main/scala/Bar.scala:18: error: Target 'Unknown label of file bazel-out/k8-fastbuild/bin/external/maven/v1/https/jcenter.bintray.com/org/scala-lang/scala-library/2.11.12/stamped_scala-library-2.11.12.jar which came from @maven//:com_fasterxml_jackson_module_jackson_module_scala_2_11' is used but isn't explicitly declared, please add it to the deps.
You can use the following buildozer command:
buildozer 'add deps Unknown label of file bazel-out/k8-fastbuild/bin/external/maven/v1/https/jcenter.bintray.com/org/scala-lang/scala-library/2.11.12/stamped_scala-library-2.11.12.jar which came from @maven//:com_fasterxml_jackson_module_jackson_module_scala_2_11' //:report
}

which has a too high noise to signal ratio for me. (Would help to shorten the paths and to remap the jars to maven).
And I cannot figure out what is wrong with my scala_library:

scala_library(
    name = "report",
    srcs = [
        "src/main/scala/Bar.scala",
        "src/main/scala/Foo.scala",
    ],
    deps = [
        "@maven//:com_fasterxml_jackson_core_jackson_databind",
        "@maven//:com_fasterxml_jackson_module_jackson_module_scala_2_11",
        "@maven//:com_typesafe_scala_logging_scala_logging_api_2_11",
        "@maven//:com_typesafe_scala_logging_scala_logging_slf4j_2_11",
        "@maven//:joda_time_joda_time",
        "@maven//:org_scalaj_scalaj_http_2_11",
    ],
)

@liucijus
Copy link
Collaborator

rules_scala since #1183 supports loading target labels from stamped jars. For example with rules_jvm_external external jars can be stamped with --@rules_jvm_external//settings:stamp_manifest=True setting.

bazel build --@rules_jvm_external//settings:stamp_manifest=True //...

scala_import stamps imported jars since #1160

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