Every time I run dist to generate the production environment I get the following warnings:
[warn] Scala version was updated by one of library dependencies:
[warn] * org.scala-lang:scala-compiler:2.11.0 -> 2.11.8
[warn] To force scalaVersion, add the following:
[warn] ivyScala := ivyScala.value map { _.copy(overrideScalaVersion = true) }
[warn] Run 'evicted' to see detailed eviction warnings
Now, in build.sbt I have the following line:
scalaVersion := "2.11.12"
I changed it from "2.11.8" when I installed a cats library as the installation said that Scala version was migrated to 2.11.12.
Should I ignore the dist message?
The problem is described here: Github sbt
The issue is still open.
It proposes:
Reflecting the scalaVersion mediator, we could issue a warning like:
[warn] Some library dependencies use a newer Scala version than this project:
[warn] * org.scala-lang:scala-library:2.12.0 -> 2.12.1
[warn] We recommend you upgrade to the latest scalaVersion patch:
[warn] scalaVersion := 2.12.1 if we know that the mediator is turned on.
Related
I'm trying to build the Scala hello world example for the Play framework: https://example.lightbend.com/v1/download/play-samples-play-scala-hello-world-tutorial
I'm getting this unresolved dependency:
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: org.hamcrest#hamcrest-core;1.3: org.hamcrest#hamcrest-core;1.3!hamcrest-core.pom(pom.original) origin location must be absolute: file:/home/sahandz/.m2/repository/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.pom
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn]
[warn] Note: Unresolved dependencies path:
[warn] org.hamcrest:hamcrest-core:1.3 (/home/sahandz/comdev/play-samples-play-scala-hello-world-tutorial/build.sbt#L12-13)
[warn] +- junit:junit:4.12
[warn] +- com.typesafe.play:play-test_2.13:2.7.3 ((play.sbt.PlaySettings.serviceSettings) PlaySettings.scala#L67)
[warn] +- org.scalatestplus.play:scalatestplus-play_2.13:4.0.3 (/home/sahandz/comdev/play-samples-play-scala-hello-world-tutorial/build.sbt#L11-12)
[warn] +- com.example:play-scala-seed_2.13:1.0-SNAPSHOT
Here is the build.sbt-file:
name := """play-scala-seed"""
organization := "com.example"
version := "1.0-SNAPSHOT"
lazy val root = (project in file(".")).enablePlugins(PlayScala)
scalaVersion := "2.11.12" // Previously: 2.13.0
libraryDependencies += guice
libraryDependencies += "org.scalatestplus.play" %% "scalatestplus-play" % "4.0.3" % Test
libraryDependencies += "org.hamcrest" % "hamcrest-core" % "1.3" % Test
I've changed the scala version to be the same as the one on my machine:
$ scala -version
Scala code runner version 2.11.12 -- Copyright 2002-2017, LAMP/EPFL
My SBT version is:
$ sbt sbtVersion
[info] 1.2.8
My Java version:
$ java -version
openjdk version "1.8.0_212"
OpenJDK Runtime Environment (build 1.8.0_212-8u212-b03-0ubuntu1.18.10.1-b03)
OpenJDK 64-Bit Server VM (build 25.212-b03, mixed mode)
And my Maven version (if it is relevant):
$ mvn -version
Apache Maven 3.6.0
Maven home: /usr/share/maven
Java version: 1.8.0_212, vendor: Oracle Corporation, runtime: /usr/lib/jvm/java-8-openjdk-amd64/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "4.18.0-25-generic", arch: "amd64", family: "unix"
How does this error occur? I've looked in the maven repository and it seems like the artifact exists, although it is deprecated: https://mvnrepository.com/artifact/org.hamcrest/hamcrest-core/1.3
I solved the issue by going into the ~/.ivy2 folder and deleting jars/org.hamcrest_hamcrest-core-1.3.jar and cache/org.hamcrest/. Any explanations as to why this worked are appreciated.
I'm trying to use sbt-scapegoat by adding this to plugins.sbt:
addSbtPlugin("com.sksamuel.scapegoat" %% "sbt-scapegoat" % "1.0.4")
Then in by build.scala file I'm doing this:
import com.sksamuel.scapegoat.sbt.ScapegoatSbtPlugin.autoImport._
scapegoatVersion := "1.1.0"
This is what's shown on the sbt-scapegoat github site. I fire up sbt and let it resolve sbt-scapegoat 1.0.4, which it does. So far so good. Then if I run scapegoat I get:
[info] Resolving com.sksamuel.scapegoat#scalac-scapegoat-plugin_2.10;1.0.0 ...
[warn] Host repo1.maven.org not found. url=https://repo1.maven.org/maven2/com/sksamuel/scapegoat/scalac-scapegoat-plugin_2.10/1.0.0/scalac-scapegoat-plugin_2.10-1.0.0.pom
[info] You probably access the destination server through a proxy server that is not well configured.
[warn] module not found: com.sksamuel.scapegoat#scalac-scapegoat-plugin_2.10;1.0.0
[warn] ==== local: tried
[warn] /Users/wmy965/.ivy2/local/com.sksamuel.scapegoat/scalac-scapegoat-plugin_2.10/1.0.0/ivys/ivy.xml
[warn] ==== public: tried
[warn] https://repo1.maven.org/maven2/com/sksamuel/scapegoat/scalac-scapegoat-plugin_2.10/1.0.0/scalac-scapegoat-plugin_2.10-1.0.0.pom
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: com.sksamuel.scapegoat#scalac-scapegoat-plugin_2.10;1.0.0: not found
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
Where is 1.0.0 dependency coming from? My project is scala 2.11.7 and I'm using sbt 0.13.11. I don't see any mention of another resolver on the sbt-scapegoat web site.
In my output, my console shows a bunch of found analysis errors but the generated HTML doc is basically empty--doesn't show the errors displayed on the console.
How can I fix this?
To set scapegoatVersion for subprojects, you need to either put it in common settings as described here, or use scapegoatVersion in ThisBuild := "1.1.0". To avoid the error, I think setting scalaVersion in the root project would work:
lazy val root = (project in file(".")).
aggregate(dotdash, dotdash_messages).
settings(
scalaVersion := "2.11.7"
)
or again use scalaVersion in ThisBuild.
I also suggest raising an issue at https://github.com/sksamuel/sbt-scapegoat.
In addition to the above answer from Alexey, Just to answer WHERE, you may want to check ScapegoatPlugin.scala.
This is an sbt Auto Plugin and the method buildSettings have overridden the scapegoatVersion to be used.
override def buildSettings = super.buildSettings ++ Seq(
scapegoatVersion := "1.0.0",
scapegoatRunAlways := true,
scapegoatConsoleOutput := true,
scapegoatVerbose := true,...
We can specify the version we choose to use, scapegoatVersion in ThisBuild.
For me nothing from above works, so potentially there are two problems and mine has been resolved by using fixed version of plugin
addSbtPlugin("com.sksamuel.scapegoat" %% "sbt-scapegoat" % "1.0.9")
I started seeing the following warning messages when doing sbt build:
[warn] Scala version was updated by one of library dependencies:
[warn] * org.scala-lang:scala-library:(2.11.1, 2.11.7, 2.11.2, 2.11.6, 2.11.5, 2.11.0) -> 2.11.8
[warn] To force scalaVersion, add the following:
[warn] ivyScala := ivyScala.value map { _.copy(overrideScalaVersion = true) }
[warn] Run 'evicted' to see detailed eviction warnings
Why is this? I'm on sbt 0.13.11!
Did something change with the sbt version? I guess I was on 0.13.5 before and did not see any warning of this sort!
It means your project defines a Scala version smaller than 2.11.8, but sbt decided to increase it to 2.11.8 because one of the dependencies uses that version. It shouldn't matter because these versions are binary compatible. I guess it warns you because you might have deliberately used a smaller version because of some regression, and in that case you would need to force a smaller Scala version using the explanation. In other cases, just ignore the warning or increase your project's Scala version to the latest (2.11.8).
I'm not sure if adding / changing Scala version would be benign. So I just added the following to my build.sbt to get rid of the warnings:
evictionWarningOptions in update :=
EvictionWarningOptions.default
.withWarnTransitiveEvictions(false)
.withWarnDirectEvictions(false)
.withWarnScalaVersionEviction(false)
It even though I have scalaVersion set to 2.11.7, my project wants to build with Scala 2.10.x.
Every time I recompile a new directory src/main/scala2.10 appears in my project. I'm pretty sure that this must be the result of an SBT reconfiguration, but what exactly is causing this, and how do I fix it?
I have a very simple [project_root]/build.sbt file:
name := "coolproduct"
version := "0.0.1"
lazy val scalaVersion = "2.11.7"
lazy val akkaVersion = "2.4.1"
libraryDependencies += "com.typesafe.akka" %% "akka-actor" % akkaVersion
When I run this script it seems to be trying to use Scala 2.10 - a totally different version to what I actually asked for:
> sbt compile
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0
[info] Loading project definition from C:\Users\salim\workspace\funproxy\project
[info] Set current project to funproxy (in build file:/C:/Users/salim/workspace/funproxy/)
[info] Updating {file:/C:/Users/salim/workspace/funproxy/}funproxy...
[info] Resolving com.typesafe.akka#akka-actor_2.10;2.4.1 ...
[warn] module not found: com.typesafe.akka#akka-actor_2.10;2.4.1
[warn] ==== local: tried
[warn] C:\Users\salim\.ivy2\local\com.typesafe.akka\akka-actor_2.10\2.4.1\ivys\ivy.xml
[warn] ==== jcenter: tried
[warn] https://jcenter.bintray.com/com/typesafe/akka/akka-actor_2.10/2.4.1/akka-actor_2.10-2.4.1.pom
[warn] ==== public: tried
[warn] https://repo1.maven.org/maven2/com/typesafe/akka/akka-actor_2.10/2.4.1/akka-actor_2.10-2.4.1.pom
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: com.typesafe.akka#akka-actor_2.10;2.4.1: not found
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn]
[warn] Note: Unresolved dependencies path:
[warn] com.typesafe.akka:akka-actor_2.10:2.4.1 (C:\Users\salim\workspace\funproxy\build.sbt#L22-23)
[warn] +- default:funproxy_2.10:0.0.1
I'm running an up to date version of SBT:
> sbt about
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0
[info] Loading project definition from C:\Users\salim\workspace\funproxy\project
[info] Set current project to funproxy (in build file:/C:/Users/salim/workspace/funproxy/)
[info] This is sbt 0.13.8
[info] The current project is {file:/C:/Users/salim/workspace/funproxy/}funproxy 0.0.1
[info] The current project is built against Scala 2.10.4
[info] Available Plugins: sbt.plugins.IvyPlugin, sbt.plugins.JvmPlugin, sbt.plugins.CorePlugin, sbt.plugins.JUnitXmlReportPlugin
[info] sbt, sbt plugins, and build definitions are using Scala 2.10.4
The short answer: change lazy val scalaVersion = "2.11.7" to:
scalaVersion := "2.11.7"
scalaVersion is not just a local scala var (or val) you can override; it's defined internally as a Key (see Keys). With the := operation you're changing the internal state of that key.
I use
name := "sbt-publish-test"
version := "0.1-SNAPSHOT"
publishTo := Some(Resolver.file("sbt-repo", file("/home/pishen/sbt-repo")))
and sbt publish to publish my project into the directory.
Now in another project, I want to resolve the project I just published. I use
resolvers += "my-repo" at "file:///home/pishen/sbt-repo"
libraryDependencies += "default" %% "sbt-publish-test" % "0.1-SNAPSHOT"
and is able to resolve the project without any error. The result of show resolvers is:
> show resolvers
[info] List(my-repo: file:///home/pishen/sbt-repo)
But, when I use
resolvers += Resolver.file("my-repo", file("/home/pishen/sbt-repo"))
libraryDependencies += "default" %% "sbt-publish-test" % "0.1-SNAPSHOT"
The result of show resolvers become:
> show resolvers
[info] List(FileRepository(my-repo,FileConfiguration(true,None),Patterns(ivyPatterns=List(), artifactPatterns=List(/home/pishen/sbt-repo/[organisation]/[module](_[scalaVersion])(_[sbtVersion])/[revision]/[artifact]-[revision](-[classifier]).[ext]), isMavenCompatible=true, descriptorOptional=false, skipConsistencyCheck=false)))
and sbt said that it can't resolve the dependency when I typed sbt update:
[warn] module not found: default#sbt-publish-test_2.10;0.1-SNAPSHOT
[warn] ==== local: tried
[warn] /home/pishen/.ivy2/local/default/sbt-publish-test_2.10/0.1-SNAPSHOT/ivys/ivy.xml
[warn] ==== public: tried
[warn] https://repo1.maven.org/maven2/default/sbt-publish-test_2.10/0.1-SNAPSHOT/sbt-publish-test_2.10-0.1-SNAPSHOT.pom
[warn] ==== my-repo: tried
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: default#sbt-publish-test_2.10;0.1-SNAPSHOT: not found
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
Is this a bug? Or am I use Resolver.file() in a wrong way? What's the difference between "name" at "url" and Resolver.file()? I'm using sbt 0.13.7.
My suspicion is that when you use Resolver.file in that context, it's intended to be more of a "builder" creator, expecting subsequent method calls to fill in additional configuration information that have different defaults when using the "name" at "uri" syntax.
The sbt ScalaDoc for Resolver.file.apply alludes to something along these lines:
Constructs a file resolver with the given name. The patterns to use must be explicitly specified using the ivys or artifacts methods on the constructed resolver object.
When I've done something similar to what you're doing, I start with a File and use its API to convert it into the URI form:
resolvers += "my-repo" at file("/home/pishen/sbt-repo").toURI.toASCIIString