Unresolved dependency hamcrest-core in SBT build - scala

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.

Related

Play production environment generation throws warnings

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.

Why does sbt use a different version of Scala to the one I asked for?

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.

Unresolved dependency SBT, scalariform

I am receiving this compilation error:
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: com.typesafe.sbt#sbt-scalariform;1.3.0: not found
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn]
[warn] Note: Some unresolved dependencies have extra attributes. Check that these dependencies exist with the requested attributes.
[warn] com.typesafe.sbt:sbt-scalariform:1.3.0 (scalaVersion=2.11, sbtVersion=0.13)
[warn]
In the root of my project I have a build.sbt file:
scalaVersion in ThisBuild := "2.11.6"
I also have a core/build.sbt file with several resolvers, libraryDependencies, and exclusions.
project/plugins.sbt:
addSbtPlugin(...)
resolvers += "Typesafe Public Repo" at "http://repo.typesafe.com/typesafe/releases"
resolvers += "JBoss Repository" at "http://repository.jboss.org/nexus/content/groups/public//"
~/.sbt/0.13/global.sbt
scalaVersion := "2.11.6"
You need to remove scalaVersion := "2.11.6" from ~/.sbt/0.13/global.sbt.
In sbt 0.13, sbt and its ecosystem of plugins is current using Scala 2.10.
The sbt-scalariform changed the groupId/organization
1.3.0 - "com.typesafe.sbt" % "sbt-scalariform" % "1.3.0"
available only for scala 2.9.1, 2.9.2 and 2.10
sbt 0.13
as seen here: https://dl.bintray.com/sbt/sbt-plugin-releases/com.typesafe.sbt/sbt-scalariform/scala_2.10/sbt_0.13/1.3.0/
1.4.0, 1.5.0, ... , 1.8.2 - "org.scalariform" % "sbt-scalariform" & "1.8.2"
https://repo1.maven.org/maven2/org/scalariform/sbt-scalariform_2.10_0.13/
https://search.maven.org/#search%7Cga%7C1%7Ca%3A%22sbt-scalariform%22

UNRESOLVED DEPENDENCIES error while trying to create jar

I'm trying to build a Scala jar file to run it in spark.
I'm following this tutorial.
when trying to build jar file using sbt as here, i'm facing with following error
[info] Resolving org.apache.spark#spark-core_2.10.4;1.0.2 ...
[warn] module not found: org.apache.spark#spark-core_2.10.4;1.0.2
[warn] ==== local: tried
[warn] /home/hduser/.ivy2/local/org.apache.spark/spark-core_2.10.4/1.0.2/ivys/ivy.xml
[warn] ==== Akka Repository: tried
[warn] http://repo.akka.io/releases/org/apache/spark/spark-core_2.10.4/1.0.2/spark-core_2.10.4-1.0.2.pom
[warn] ==== public: tried
[warn] http://repo1.maven.org/maven2/org/apache/spark/spark-core_2.10.4/1.0.2/spark-core_2.10.4-1.0.2.pom
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: org.apache.spark#spark-core_2.10.4;1.0.2: not found
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[error] {file:/home/prithvi/scala/asd/}default-d57abf/*:update: sbt.ResolveException: unresolved dependency: org.apache.spark#spark-core_2.10.4;1.0.2: not found
[error] Total time: 2 s, completed 13 Aug, 2014 5:24:24 PM
what's the issue and how to solve it.
Dependency issue has been resolved. Thank you "om-nom-nom"but new error arised
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: FAILED DOWNLOADS ::
[warn] :: ^ see resolution messages for details ^ ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: org.eclipse.jetty.orbit#javax.transaction;1.1.1.v201105210645!javax.transaction.orbit
[warn] :: org.eclipse.jetty.orbit#javax.servlet;3.0.0.v201112011016!javax.servlet.orbit
[warn] :: org.eclipse.jetty.orbit#javax.mail.glassfish;1.4.1.v201005082020!javax.mail.glassfish.orbit
[warn] :: org.eclipse.jetty.orbit#javax.activation;1.1.0.v201105071233!javax.activation.orbit
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[error] {file:/home/prithvi/scala/asd/}default-c011e4/*:update: sbt.ResolveException: download failed: org.eclipse.jetty.orbit#javax.transaction;1.1.1.v201105210645!javax.transaction.orbit
[error] download failed: org.eclipse.jetty.orbit#javax.servlet;3.0.0.v201112011016!javax.servlet.orbit
[error] download failed: org.eclipse.jetty.orbit#javax.mail.glassfish;1.4.1.v201005082020!javax.mail.glassfish.orbit
[error] download failed: org.eclipse.jetty.orbit#javax.activation;1.1.0.v201105071233!javax.activation.orbit
[error] Total time: 855 s, completed 14 Aug, 2014 12:28:33 PM
You have your dependency defined as
"org.apache.spark" %% "spark-core" % "1.0.2"
That %% instructs sbt to substitute current scala version to artifact name. Apparently, spark was build for the whole family of 2.10 scala, without specific jars for 2.10.1, 2.10.2 ...
So all you have to do is to redefine it as:
"org.apache.spark" % "spark-core_2.10" % "1.0.2"
I had the same issue.
Looks like that some bugs are in different versions/compilations/etc.
For me the following build.sbt worked fine
name := "My Project"
version := "1.0"
scalaVersion := "2.11.8"
libraryDependencies += "org.apache.spark" %% "spark-sql" % "2.3.2"
Hope it helps
spark-core_2.10.4;1.0.2 means that it is build on top of scala 2.10 vesion.
so you have to specified this scalaVersion := "2.10.4" in your build file.
Please check your .sbt file and change accordingly.
libraryDependencies ++= Seq(
"org.apache.spark" %% "spark-core" % "1.1.0",
"org.eclipse.jetty.orbit" % "javax.servlet" % "3.0.0.v201112011016",
"org.eclipse.jetty.orbit" % "javax.transaction" % "1.1.1.v201105210645",
"org.eclipse.jetty.orbit" % "javax.mail.glassfish" % "1.4.1.v201005082020"
)
How can you change the current dependencies? I mean, when you type sbt package for a build file like:
name := "Simple Project"
version := "1.0"
scalaVersion := "2.10.4"
libraryDependencies += "org.apache.spark" %% "spark-core" % "1.2.0"
SBT will start resolving and downloading all kinds of dependencies. But if you see that it is failing on a dependency that is no longer inthe maven repo, what to do? Where can you change the dpencies it tries.
#OP: The problem is that your SBT is outdated. If you downloaded it using apt, you can use apt to remove it as well. In any case, download the latest .tgz (not the .deb) and simply unpack it, after that add the /sbt/bin/ folder to your .bashrc I noticed that older SBT's (the .deb and apt-get versions) work with older scala versions. You either need to manually add or change the dependencies that the older SBT is trying to find or simply change to the latest (not sooo)SBT.

unresolved dependency: com.typesafe.play#play-slick_2.10;0.6.0.1: not found

I am getting unresolved dependencies errors when trying to use slick or play-slick with Play Framework 2.2.2, sbt 0.13.0 and Scala 2.10.3 on Mac OS X Mavericks.
[info] Updating {file:/Users/michaelrichardson/Documents/Play/glasgowEffect/}glasgoweffect...
[info] Resolving com.typesafe.play#slick_2.10;2.0.0 ...
[warn] module not found: com.typesafe.play#slick_2.10;2.0.0
[warn] ==== Typesafe Releases Repository: tried
[warn] http://repo.typesafe.com/typesafe/releases/com/typesafe/play/slick_2.10/2.0.0/slick_2.10-2.0.0.pom
[info] Resolving com.typesafe.play#play-slick_2.10;0.6.0.1 ...
[warn] module not found: com.typesafe.play#play-slick_2.10;0.6.0.1
[warn] ==== Typesafe Releases Repository: tried
[warn] http://repo.typesafe.com/typesafe/releases/com/typesafe/play/play-slick_2.10/0.6.0.1/play-slick_2.10-0.6.0.1.pom
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: com.typesafe.play#slick_2.10;2.0.0: not found
[warn] :: com.typesafe.play#play-slick_2.10;0.6.0.1: not found
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[trace] Stack trace suppressed: run last *:update for the full output.
[error] (*:update) sbt.ResolveException: unresolved dependency: com.typesafe.play#slick_2.10;2.0.0: not found
[error] unresolved dependency: com.typesafe.play#play-slick_2.10;0.6.0.1: not found
[error] Total time: 7 s, completed Apr 27, 2014 2:58:48 PM
I have tried clearing my ivy cache, running play clean and adding different resolvers but nothing has worked.
This is the build.sbt file:
name := "Test"
version := "1.0-SNAPSHOT"
libraryDependencies ++= Seq(
jdbc,
anorm,
cache,
"com.typesafe.slick" %% "slick" % "2.0.0",
"com.typesafe.play" %% "play-slick" % "0.6.0.1"
)
play.Project.playScalaSettings
UPDATE: Looked into resolvers
[play21-osm] $ show resolvers
[info] List(Typesafe Releases Repository: http://repo.typesafe.com/typesafe/releases/, Typesafe Releases: http://typesafe.artifactoryonline.com/typesafe, pk11 repo: http://pk11-scratch.googlecode.com/svn/trunk)
[play21-osm] $ show externalResolvers
[info] ArrayBuffer(FileRepository(local,FileConfiguration(true,None),Patterns(ivyPatterns=List(${ivy.home}/local/[organisation]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/artifact.[ext]), artifactPatterns=List(${ivy.home}/local/[organisation]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/artifact.[ext]), isMavenCompatible=false)), Maven2 Local: file:/Users/mr/.m2/repository, public: http://repo1.maven.org/maven2/, Typesafe Releases Repository: http://repo.typesafe.com/typesafe/releases/, Typesafe Releases: http://typesafe.artifactoryonline.com/typesafe, pk11 repo: http://pk11-scratch.googlecode.com/svn/trunk)
Quit Play Console, and make sure your build.sbt looks like this:
name := "Test"
version := "1.0-SNAPSHOT"
libraryDependencies ++= Seq(
jdbc,
anorm,
cache,
"com.typesafe.slick" %% "slick" % "2.0.0",
"com.typesafe.play" %% "play-slick" % "0.6.0.1"
)
play.Project.playScalaSettings
Delete $PLAY_HOME/repository/cache/com.typesafe.slick and $PLAY_HOME/repository/cache/com.typesafe.play/play-slick_2.10. You may want to delete complete cache directory if you like to.
Run Play console again and execute update followed by compile.
Your slick dependency has the wrong group name. It should be com.typesafe.slick instead of com.typesafe.play:
"com.typesafe.slick" %% "slick" % "2.0.0"
Very hard to tell if this really was what fixed the problem but it is now working for me.
cd ~
brew uninstall sbt
brew uninstall play
mv .sbt .sbtold
mv .ivy2 .ivy2old
brew install sbt
brew install play
sbt
play
sbt clean
I think that my sbt or ivy repositories had become corrupted and this resulted in them being rebuilt.