Scala doesn't like runtime dependencies?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Scala doesn't like runtime dependencies?

Shannon Carey

I'm using Scala 2.11.7. I am trying to use a library https://bitbucket.org/marshallpierce/hdrhistogram-metrics-reservoir which has a runtime dependency on org.hdrhistogram:HdrHistogram which contains the class org.HdrHistogram.Recorder. Compilation fails with Scala complaining:


[ERROR] error: Class org.HdrHistogram.Recorder not found - continuing with a stub.

Why does this happen?


What should I do? Do I have to punt and manually specify the dependency as "compile" scope so that it's present on the compilation classpath? I don't want to do that unless I need to because it dirties my build with Scala-specific voodoo (I'll have to use a comment to demystify).


Also, while I'm at it let me encourage those working on new versions of Scala to improve the Java interop & improve handling of types & implicits... right now those aspects of Scala are often a combination of difficult, frustrating, and surprising.


Thanks!

--
You received this message because you are subscribed to the Google Groups "scala-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Scala doesn't like runtime dependencies?

Oliver Ruebenacker

     Hello,

  As far as I know, if your project has a class A which refers to a library class B which refers to a library class C, then you want both classes B and C on the class path, both for compiling and running. Even if B and C are in different libraries. That's why usually the library that contains B lists the library that contains C as a dependency, and typical build tools will, when you specify the B-library, automatically pull in the C-library for compiling and running.

  So, I'm confused what is going on in your case. Does the library you are using fail to correctly specify its dependencies? Or are you trying to compile without automatic dependency resolution? How do you compile, and how do you specify your dependency?

     Best, Oliver

On Tue, Feb 14, 2017 at 1:48 PM, Shannon Carey <[hidden email]> wrote:

I'm using Scala 2.11.7. I am trying to use a library https://bitbucket.org/marshallpierce/hdrhistogram-metrics-reservoir which has a runtime dependency on org.hdrhistogram:HdrHistogram which contains the class org.HdrHistogram.Recorder. Compilation fails with Scala complaining:


[ERROR] error: Class org.HdrHistogram.Recorder not found - continuing with a stub.

Why does this happen?


What should I do? Do I have to punt and manually specify the dependency as "compile" scope so that it's present on the compilation classpath? I don't want to do that unless I need to because it dirties my build with Scala-specific voodoo (I'll have to use a comment to demystify).


Also, while I'm at it let me encourage those working on new versions of Scala to improve the Java interop & improve handling of types & implicits... right now those aspects of Scala are often a combination of difficult, frustrating, and surprising.


Thanks!

--
You received this message because you are subscribed to the Google Groups "scala-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.



--
Oliver Ruebenacker
Senior Software Engineer, Diabetes Portal, Broad Institute

--
You received this message because you are subscribed to the Google Groups "scala-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Scala doesn't like runtime dependencies?

Jasper-M
In reply to this post by Shannon Carey
Hi Shannon,

I think this is the same issue as this one: http://stackoverflow.com/questions/13856266/class-broken-error-with-joda-time-using-scala

The reason is in the comments to the accepted answer. I'm afraid there's not much else to do than specifying the extra dependency.

Kind regards,
Jasper

--
You received this message because you are subscribed to the Google Groups "scala-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Scala doesn't like runtime dependencies?

Jason Zaugg
We're actively working on making the compiler more robust against absent transitive dependencies. It is a bit of a game of whack a mole, but progress is being made.
On Wed, 15 Feb 2017 at 08:44, Jasper-M <[hidden email]> wrote:
Hi Shannon,

I think this is the same issue as this one: http://stackoverflow.com/questions/13856266/class-broken-error-with-joda-time-using-scala

The reason is in the comments to the accepted answer. I'm afraid there's not much else to do than specifying the extra dependency.

Kind regards,
Jasper

--
You received this message because you are subscribed to the Google Groups "scala-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "scala-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Scala doesn't like runtime dependencies?

Shannon Carey
In reply to this post by Oliver Ruebenacker
Jasper & Jason, thanks for the responses. I'll include the dependency as "compile" scope.

Oliver,

Yes, most of the time you want transitive dependencies to be on the compile classpath. However, there are times that you don't want that. Most of the time, it's when you should be programming against an API and only have an implementation of the API present on the classpath at runtime. The main example that comes to my mind is Slf4j. You only want slf4j-api as a compile dependency, and you want the implementation (Logback, Log4j, etc.) only on your runtime classpath. Another example of that would be "optional" dependencies in Maven. For example, you may want to allow people to pick different AOP approaches: bytecode manipulation, proxies, etc. without actually compiling anything against them.

I am using Maven. Maven transitive dependency scope rules can be found here: https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Dependency_Scope


On Tuesday, February 14, 2017 at 3:47:32 PM UTC-6, Oliver Ruebenacker wrote:

     Hello,

  As far as I know, if your project has a class A which refers to a library class B which refers to a library class C, then you want both classes B and C on the class path, both for compiling and running. Even if B and C are in different libraries. That's why usually the library that contains B lists the library that contains C as a dependency, and typical build tools will, when you specify the B-library, automatically pull in the C-library for compiling and running.

  So, I'm confused what is going on in your case. Does the library you are using fail to correctly specify its dependencies? Or are you trying to compile without automatic dependency resolution? How do you compile, and how do you specify your dependency?

     Best, Oliver

On Tue, Feb 14, 2017 at 1:48 PM, Shannon Carey <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="Qrqz0SwuCgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">rehe...@...> wrote:

I'm using Scala 2.11.7. I am trying to use a library <a href="https://bitbucket.org/marshallpierce/hdrhistogram-metrics-reservoir" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fbitbucket.org%2Fmarshallpierce%2Fhdrhistogram-metrics-reservoir\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEQyID23rJGZAxXleEo1PRXr82OtQ&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fbitbucket.org%2Fmarshallpierce%2Fhdrhistogram-metrics-reservoir\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEQyID23rJGZAxXleEo1PRXr82OtQ&#39;;return true;">https://bitbucket.org/marshallpierce/hdrhistogram-metrics-reservoir which has a runtime dependency on org.hdrhistogram:HdrHistogram which contains the class org.HdrHistogram.Recorder. Compilation fails with Scala complaining:


[ERROR] error: Class org.HdrHistogram.Recorder not found - continuing with a stub.

Why does this happen?


What should I do? Do I have to punt and manually specify the dependency as "compile" scope so that it's present on the compilation classpath? I don't want to do that unless I need to because it dirties my build with Scala-specific voodoo (I'll have to use a comment to demystify).


Also, while I'm at it let me encourage those working on new versions of Scala to improve the Java interop & improve handling of types & implicits... right now those aspects of Scala are often a combination of difficult, frustrating, and surprising.


Thanks!

--
You received this message because you are subscribed to the Google Groups "scala-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="Qrqz0SwuCgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">scala-user+...@googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.



--
Oliver Ruebenacker
Senior Software Engineer, <a href="http://www.type2diabetesgenetics.org/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.type2diabetesgenetics.org%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFVE8xTGqlzANyuan2sVDo75uy-vA&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.type2diabetesgenetics.org%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFVE8xTGqlzANyuan2sVDo75uy-vA&#39;;return true;">Diabetes Portal, <a href="http://www.broadinstitute.org/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.broadinstitute.org%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHloBLjHUP5Yhb6LyVOZ-JE5b4Y5A&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.broadinstitute.org%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHloBLjHUP5Yhb6LyVOZ-JE5b4Y5A&#39;;return true;">Broad Institute

--
You received this message because you are subscribed to the Google Groups "scala-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.