Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    Max Walker
    @SegFaultx64
    I am assuming the issue here might be with dependencies.yaml:
    options:
      languages: [ "java", "scala:2.12.8" ]
      transitivity: exports
      buildHeader:
      - load("@io_bazel_rules_scala//scala:scala_import.bzl", "scala_import")
    
    dependencies:
      org.typelevel:
        cats:
          version: "2.0.0"
          lang: scala
          modules:
            - core
      io.circe:
        circe:
          version: "0.12.3"
          lang: "scala"
          modules:
            - core
            - generic
            - parser
        circe-generic:
          version: "0.12.3"
          lang: scala
      com.chuusai:
        shapeless:
          version: "2.3.3"
          lang: "scala"
    I came across this snippet online but i couldn't get it to work:
          exports: # due to the macros, these need to be here at compile time
            - "com.chuusai:shapeless"
            - "io.circe:circe-core"
            - "org.typelevel:cats-core"
            - "org.typelevel:cats-kernel"
    Max Walker
    @SegFaultx64
    I actually got it working under 2.11 using the macros paradise compiler plugin, but I can't get that compiler plugin to work in 2.12 for some reason
    Max Walker
    @SegFaultx64
    Finally got it working. The exceptionally dumb root issue was that I was calling scala_repositories(( twice which meant I was not using the right scala version which was causing me to need the macro paradise plugin which I couldn't use for some reason
    Ghost
    @ghost~54c6a0bddb8155e6700f1b4a
    Ahhhh interesting!
    Well thats interesting to hear as a cause of it. Good too hear your all unblocked
    Bardur Arantsson
    @BardurArantsson

    Hi all,

    I'm trying to compile some scala code that uses ScalaTest, but I'm seeing errors like the following:

    error: exception during macro expansion:
    java.lang.NoClassDefFoundError: scala/runtime/LazyRef
            at org.scalactic.MacroOwnerRepair$Utils.repairOwners(MacroOwnerRepair.scala:66)
            at org.scalactic.MacroOwnerRepair.repairOwners(MacroOwnerRepair.scala:46)
            at org.scalactic.BooleanMacro.genMacro(BooleanMacro.scala:837)
            at org.scalatest.AssertionsMacro$.assert(AssertionsMacro.scala:34)
            at jdk.internal.reflect.GeneratedMethodAccessor45.invoke(Unknown Source)
            at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
            at java.base/java.lang.reflect.Method.invoke(Method.java:566)
            at scala.reflect.macros.runtime.JavaReflectionRuntimes$JavaReflectionResolvers$$anonfun$resolveJavaReflectionRuntime$2.apply(JavaReflectionRuntimes.scala:34)
            at scala.reflect.macros.runtime.JavaReflectionRuntimes$JavaReflectionResolvers$$anonfun$resolveJavaReflectionRuntime$2.apply(JavaReflectionRuntimes.scala:22)
            at scala.tools.nsc.typechecker.Macros$class.macroExpandWithRuntime(Macros.scala:763)

    My dependencies.yml contains this:

      org.scalatest:
        scalatest_2.12:
          version: "3.0.5"
          lang: scala/unmangled
    
      org.scalactic:
        scalactic_2.12:
          lang: scala/unmangled

    (I'm using bazel_deps.)

    and in the BUILD file I have

    scala_import(
        name = "scalatest",
        jars = [
            "//3rdparty/jvm/org/scalatest:scalatest_2_12",
            "//3rdparty/jvm/org/scalactic:scalactic_2_12",
        ],
    )

    and my project (defined in the same BUILD file) then lists :scalatest as a dep.

    I gather that this is some sort of problem with Scala Macros, but I'm a total Bazel noob and could definitely use some hints on why this doesn't work :)

    (Based on some Googling, I've tried to supply --nouse_ijars, but that doesn't seem to have any effect. I suppose that's perhaps just for macros defined inside the repo itself and no external macros?)

    Oh, yes, and I've also tried with regular 'scala' dependencies rather than scala/unmangled, but I'm guessting that that shouldn't really matter.

    Ghost
    @ghost~54c6a0bddb8155e6700f1b4a
    You shouldn’t need the scala import. Those 3rd party targets are already scala imports I think
    I suspect there’s an export maybe needed. Can you put some repo case in a github repo so I can look ?
    Bardur Arantsson
    @BardurArantsson

    It's unfortunately the code is proprietary, and it would quite a lot of work to disentangle the build bits from the code :(

    Would just having the full contents of dependencies.yml + BUILD help diagnosing it? (Those aren't proprietary)

    I should say, btw, that the code I'm compiling is using scala_library not scala_test (it's basically a test-kit type thing where I expect other libraries to depend on it for their own tests).
    Bardur Arantsson
    @BardurArantsson
    Nvm, actually I'm dumb... It shouldn't actually be too hard to just strip away all the code. BRB.
    Ghost
    @ghost~54c6a0bddb8155e6700f1b4a
    Ok great.
    Bardur Arantsson
    @BardurArantsson
    Ghost
    @ghost~54c6a0bddb8155e6700f1b4a
    @BardurArantsson your compiling against Scala 2.11
    happily a relatively easy fix there
    ignoring the updates from running the bazel-deps tool, that's the diff I have
    most of it is just cleaning some stuff up to maybe bit a little simpler for you, so thats largely ignorable
    scala_repositories((
      "2.12.10",
      {
          "scala_compiler": "cedc3b9c39d215a9a3ffc0cc75a1d784b51e9edc7f13051a1b4ad5ae22cfbc0c",
          "scala_library": "0a57044d10895f8d3dd66ad4286891f607169d948845ac51e17b4c1cf0ab569d",
          "scala_reflect": "56b609e1bab9144fb51525bfa01ccd72028154fc40a58685a1e9adcbe7835730",
      },
    ))
    Thats the key bit you need to ddo
    Bardur Arantsson
    @BardurArantsson
    D'oh... Of course it was something simple... just been staring at it for so long...
    Thank you so much for the help!
    Just a quick question: What is the "export" bit doing? Does it just mean that scalactic will be "bundled" into the "//3rdparty/jvm/org/scalatest:scalatest" target?
    Ghost
    @ghost~54c6a0bddb8155e6700f1b4a
    no problem
    Alex Wied
    @radix-alex_gitlab
    Hi. I have two targets within a package, foo-lib and foo-bin. I see that the rules_scala rules produce separate JARs in the bazel-bin directory. I would like to produce a single JAR which contains all dependencies. How should I proceed? I am using bazel version 1.2.1.
    Ghost
    @ghost~54c6a0bddb8155e6700f1b4a
    @radix-alex_gitlab You want all the transitive dependencies is it?
    Alex Wied
    @radix-alex_gitlab
    Indeed.
    Ghost
    @ghost~54c6a0bddb8155e6700f1b4a
    bazel build my package:foo-bin_deploy.jar
    the binary targets have an extra output (java has the same thing), that is a fat jar which would contain the full set of transitive deps
    Alex Wied
    @radix-alex_gitlab
    That seems to be what I'm looking for. Thanks!
    Ittai Zeidman
    @ittaiz

    Hi,
    Next week I'm merging a huge PR which effectively rewrites rule.
    It has ben under review for 2 months and we've ran it through severa very large codebases (Wix's ~10MLOC passes with it) but I'd still suggest other companies to take it out for a spin and report on the PR bazelbuild/rules_scala#865.

    On a related note I'll say that I'm not really looking here and I've moved to bazelbuild slack's org (#scala) so you're invited there as well.
    Happy holidays

    Tobias Johansson
    @tobias-johansson
    Hi, Am I right in thinking that the scala rules (e.g. scala_library) currently doesn't add transitive dependencies to compile classpath? (the way java rules does with --strict_java_deps=off) indicated here: bazelbuild/rules_scala#235
    Any workaround to this, or do I simply need to add all actual deps (as part of migrating off maven)?
    Ittai Zeidman
    @ittaiz
    @tobias-johansson I’m mostly over at the bazelbuild slack channel then here so expect long silences from me (though Ian is very responsive here).
    You’re right that rules_scala by default adds only direct dependencies but it has a strictdeps mode of warm and error which you can probably use for your needs. This is how we started out though we had a few other tools we’ve built like exodus (available on github)
    Tobias Johansson
    @tobias-johansson
    Ok thanks @ittaiz
    Ittai Zeidman
    @ittaiz
    Also there is work underway for improving strict deps so might be worth keeping tabs on the repo
    pr0ton
    @pr0ton

    Hey folks - trying to use bazel for a demo project (on my personal dev machine not behind some corporate firewall). this is the error i get ERROR: /home/ptandel/.cache/bazel/_bazel_ptandel/1dcc102f10d8db6f292e788f608253ba/external/io_bazel_rules_scala/scala/scala.bzl:561:5: //external:io_bazel_rules_scala/dependency/scala/scala_reflect depends on @io_bazel_rules_scala_scala_reflect//:io_bazel_rules_scala_scala_reflect in repository @io_bazel_rules_scala_scala_reflect which failed to fetch. no such package '@io_bazel_rules_scala_scala_reflect//': java.io.IOException: Error downloading [http://central.maven.org/maven2/org/scala-lang/scala-reflect/2.11.12/scala-reflect-2.11.12.jar] to /home/ptandel/.cache/bazel/_bazel_ptandel/1dcc102f10d8db6f292e788f608253ba/external/io_bazel_rules_scala_scala_reflect/scala-reflect-2.11.12.jar: Unknown host: central.maven.org

    IIRC central.maven.org doesn't seem to be valid but i couldn't figure out how to specify something else (short of using a HTTP(S) proxy which I'm not sure would solve my problem)?

    pr0ton
    @pr0ton
    so seems like setting rules_scala_version to the newest version did it!
    Alex Wied
    @radix-alex_gitlab

    Hi. I am using IntelliJ, Scala, and the Bazel plugin. I am noticing that some dependencies are not resolved, leading to red font in the code window. The project builds fine from the command line however.

    In particular, I've noticed that the .ijwb/.idea/libraries/ directory is missing an entry for com_typesafe_config_2_12_foo.xml.

    In fact, my application runs fine from within IntelliJ also. IntelliJ/the Bazel plugin is not picking up the external com.typesafe.config dependency. It doesn't make sense to me because it's explicitly depended upon in my BUILD file (e.g. deps = [ "//3rdparty/jvm/com/typesafe:config" ]).
    Vadim Anufriev
    @va-anufriev

    Hello!
    Sorry about newbie question.
    Where I can find sha256 for selecting scala version in WORKSPACE file?

    https://github.com/bazelbuild/rules_scala#selecting-scala-version

    Ittai Zeidman
    @ittaiz
    Hi,
    There is a rules_scala governance doc in a world commentable google doc.
    It is very much baked (and is based on previous work mostly done by the amazing @Oscar) and the main motivation of opening it up again is to see if I haven’t missed anything.
    Re the main heated discussion of correctness and such- I’ve massaged the terminology based on suggestions here to be the most open while keeping the values I think are core.
    In ~2 weeks I plan to send and merge a PR with this doc.
    Additionally I'd like to remind you that the main discussion of these rules is happening on slack https://bazelbuild.slack.com/archives/CDCKJ2KFZ/p1599132817003300
    Parker Gordon
    @parkergordonio
    This room is more active than "Bazel Users" :smile:
    Andy Hamon
    @andrewhamon
    Hey folks -- this might be more of a general bazel question, but how do I make sure that a given scala_proto_library call uses a custom toolchain? The docs just say "To configure ScalaPB options, configure a different scala_proto_toolchain and declare it in a BUILD file". Any build file? Every build file that needs it?